Sheetjs: How to set width for Columns

Created on 26 Jun 2018  路  7Comments  路  Source: SheetJS/sheetjs

Hi,
Please help me. How to set width for Columns for excel file export.
Thank you

Most helpful comment

How to set columns autofit

All 7 comments

How to set columns autofit

Hi,
I want to convert json to .xlsx format buffer (I guess I should use this). Then I want to set width of excel columns as well ! Is that feasible with the free version of this product ?
Kind Regards,

I also want to know the method

var wscols = [
    {wch: 6}, // "characters"
    {wpx: 50}, // "pixels"
    ,
    {hidden: true} // hide column
];
ws['!cols'] = wscols;

like this
Please refer to the following link: https://github.com/SheetJS/js-xlsx/blob/master/tests/write.js#L14-L19

@fclemonschool answered the question :)

automatic cell width you can try to see it
https://github.com/dave-wind/excel

Tried both wch or width, neither works

var wscols = [ {wch:20}, {wch:30}, {wch:40}, {wch:30},{wch:10}, {wch:10}];
ws['!cols'] = wscols;

var wscols = [ {width:20}, {width:30}, {width:40}, {width:30},{wch:10}, {width:10}];
ws['!cols'] = wscols;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

upasana-shah picture upasana-shah  路  4Comments

seanmcilvenna picture seanmcilvenna  路  3Comments

mmancosu picture mmancosu  路  3Comments

DannyRyman picture DannyRyman  路  3Comments

happy0088 picture happy0088  路  3Comments