From eef2bf2815b63a739601f26b60c6ac6246793136 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:53:09 +0300 Subject: [PATCH] Update htmlTable.ts --- scripts/core/htmlTable.ts | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) 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' }