Replies: 6 comments
-
@lix928 I can work with this. import { times } from 'lodash';
times(worksheet.columnCount, (index) => {
const col: Partial<Column> = worksheet.getColumn(index + 1);
col.width = 30;
}); It is better to provide a complete test case! |
Beta Was this translation helpful? Give feedback.
-
@skypesky I can't use ts _.times(endColumn - startColumn, (index) => {
const col = sheet.getColumn(index + startColumn);
col.width = 30;
});
sheet.commit();
await excel.commit(); this is a stream excel. |
Beta Was this translation helpful? Give feedback.
-
I have the same issue. It should work in case we define it before commiting. |
Beta Was this translation helpful? Give feedback.
-
Same issue here. Looks like the only way is to set the widths before adding rows, using:
In my case, it's really not handy because I want to fit the columns to the content, which is not known in advance (streamed too). 😞 |
Beta Was this translation helpful? Give feedback.
-
Was a solution ever found for this to allow columns to be set dynamically as the data is streamed in? Also having the same issue. |
Beta Was this translation helpful? Give feedback.
-
I ended up consuming the first 100 rows of my stream, hoping they would be somewhat representative, to compute the columns widths, then inserting these rows and the rest of the stream to the worksheet... Hardly satisfying. |
Beta Was this translation helpful? Give feedback.
-
Hi, team
I have created a workbook by stream, such as
const excel = new StreamExcel({ filename: excelFilePath });
But I can't set the column width By
const sheet = excel.addSheet(sheetName, { properties: { defaultColWidth: 30 } });
;sheet.getColumn(col).width = 30;
dose't work neither. Even if I set the column width before commit each row, it doesn't work.SteamExcel is a class encapsulated by exceljs;
thank you for help, plz
Beta Was this translation helpful? Give feedback.
All reactions