import type { IPdfTable } from './types'; export class PdfTable implements IPdfTable { tableNumber: number; numrows: number; numcols: number; data: string[][]; constructor(obj: IPdfTable) { this.tableNumber = obj.tableNumber; this.numrows = obj.numrows; this.numcols = obj.numcols; this.data = obj.data; } asDelimitedText(separator = ','): string { let out = ''; for (const line of this.data) { const text = line.map(str => { if (str.includes('"')) return `"${str.replace(/"/g, '""')}"`; if (str.match(/[\s,]/)) return `"${str}"`; return str; }).join(separator); writeLn(text); } return out; function writeLn(text = '') { out += `${text}\r\n`; } } asHtml(): string { let out = '
| ${(data[i]?.[j] || ' ').replace(/`; text += ' |