[Fixed] How to set column width of XLSX worksheet in angular4


I am Converting HTML to XLSX sheet in angular using SheetJS. But the width of each column is 256 only, I want to increase it

I have tried using ws[!cols] of ColInfo but not able to correctly implement it or set it ‘wch’ & ‘width’

let worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(this.exportNoteData);

const workbook: XLSX.WorkBook = { Sheets: { 'data': worksheet }, SheetNames: ['data'] };
XLSX.writeFile(workbook, 'NoteExport.xls', { bookType: 'xls', type: 'buffer' });

I want to provide custom width for each column in generated excel, currently, I have 4 fixed columns


Use Booktype XLSX instead of XLS, to use ws[!col] in WriteFile

XLSX.writeFile(workbook, 'NoteExport.xls', { bookType: 'xlsx', type: 'buffer' });

Leave a Reply

(*) Required, Your email will not be published