I must to autosize column width with exceljs
.
My excel must be dynamic and save in Excel only the columns that the user will provide in the request. To this case I provide this syntax:
workSheet.getRow(1).values = dto.columns;
which save column name on the first row with names provided in dto.columns
.
But i must set width to each of the column, i try this:
for(let i=0; i <= dto.columns.length-1; i++) {
workSheet.columns = [
{key: dto.columns[i], width: Object.keys(dto.columns[i]).length}
]
}
but this don't set me any with :
can someone tell me how can i create an autosize
function to this problem?
thanks for any help