Skip to content

Commit

Permalink
fix: table column style bug and addTable colum type (#2649)
Browse files Browse the repository at this point in the history
* fix table column style bug and addTable colum type

* make TableColumnProperties.style optional
  • Loading branch information
jbuck-lineleap committed Jan 12, 2024
1 parent ddab279 commit 5bed18b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,11 @@ export interface TableColumnProperties {
* Optional formula for custom functions
*/
totalsRowFormula?: string;

/**
* Styles applied to the column
*/
style?: Partial<Style>;
}


Expand Down
2 changes: 1 addition & 1 deletion lib/doc/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Table {
const assignStyle = (cell, style) => {
if (style) {
Object.keys(style).forEach(key => {
cell[key] = style[key];
cell.style[key] = style[key];
});
}
};
Expand Down
8 changes: 6 additions & 2 deletions test/test-table.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Excel = require('../lib/exceljs.nodejs.js');
const Excel = require('../lib/exceljs.nodejs');
const HrStopwatch = require('./utils/hr-stopwatch');

const [, , filename] = process.argv;
Expand Down Expand Up @@ -47,14 +47,18 @@ ws.addTable({
totalsRowFunction: 'max',
filterButton: true,
totalsRowResult: 8,
style: {numFmt: '0.00%'},
},
{
name: 'Word',
filterButton: false,
style: {font: {bold: true, name: 'Comic Sans MS'}},
},
],
rows: words.map((word, i) => [new Date(+today + (86400 * i)), i, word]),
rows: words.map((word, i) => {
const additionalDays = 86400 * i;
return [new Date(today + additionalDays), i, word];
}),
});

const stopwatch = new HrStopwatch();
Expand Down

0 comments on commit 5bed18b

Please sign in to comment.