Skip to content

Commit 5bed18b

Browse files
fix: table column style bug and addTable colum type (#2649)
* fix table column style bug and addTable colum type * make TableColumnProperties.style optional
1 parent ddab279 commit 5bed18b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,11 @@ export interface TableColumnProperties {
18321832
* Optional formula for custom functions
18331833
*/
18341834
totalsRowFormula?: string;
1835+
1836+
/**
1837+
* Styles applied to the column
1838+
*/
1839+
style?: Partial<Style>;
18351840
}
18361841

18371842

lib/doc/table.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class Table {
183183
const assignStyle = (cell, style) => {
184184
if (style) {
185185
Object.keys(style).forEach(key => {
186-
cell[key] = style[key];
186+
cell.style[key] = style[key];
187187
});
188188
}
189189
};

test/test-table.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const Excel = require('../lib/exceljs.nodejs.js');
1+
const Excel = require('../lib/exceljs.nodejs');
22
const HrStopwatch = require('./utils/hr-stopwatch');
33

44
const [, , filename] = process.argv;
@@ -47,14 +47,18 @@ ws.addTable({
4747
totalsRowFunction: 'max',
4848
filterButton: true,
4949
totalsRowResult: 8,
50+
style: {numFmt: '0.00%'},
5051
},
5152
{
5253
name: 'Word',
5354
filterButton: false,
5455
style: {font: {bold: true, name: 'Comic Sans MS'}},
5556
},
5657
],
57-
rows: words.map((word, i) => [new Date(+today + (86400 * i)), i, word]),
58+
rows: words.map((word, i) => {
59+
const additionalDays = 86400 * i;
60+
return [new Date(today + additionalDays), i, word];
61+
}),
5862
});
5963

6064
const stopwatch = new HrStopwatch();

0 commit comments

Comments
 (0)