diff --git a/scripts/core/htmlTable.ts b/scripts/core/htmlTable.ts index 72d6bd8d..144ba01b 100644 --- a/scripts/core/htmlTable.ts +++ b/scripts/core/htmlTable.ts @@ -2,9 +2,15 @@ type Column = { name: string nowrap?: boolean align?: string + colspan?: number } -type DataItem = string[] +type DataItem = { + value: string + nowrap?: boolean + align?: string + colspan?: number +}[] export class HTMLTable { data: DataItem[] @@ -20,20 +26,23 @@ export class HTMLTable { output += ' \r\n ' for (const column of this.columns) { - output += `${column.name}` + const nowrap = column.nowrap ? ' nowrap' : '' + const align = column.align ? ` align="${column.align}"` : '' + const colspan = column.colspan ? ` colspan="${column.colspan}"` : '' + + output += `${column.name}` } output += '\r\n \r\n' output += ' \r\n' - for (const item of this.data) { + for (const row of this.data) { output += ' ' - let i = 0 - for (const prop in item) { - const column = this.columns[i] - const nowrap = column.nowrap ? ' nowrap' : '' - const align = column.align ? ` align="${column.align}"` : '' - output += `${item[prop]}` - i++ + for (const item of row) { + const nowrap = item.nowrap ? ' nowrap' : '' + const align = item.align ? ` align="${item.align}"` : '' + const colspan = item.colspan ? ` colspan="${item.colspan}"` : '' + + output += `${item.value}` } output += '\r\n' }