protobi / js-xlsx

XLSX / XLSM / XLSB (Excel 2007+ Spreadsheet) / ODS parser and writer
http://oss.sheetjs.com/js-xlsx
Other
817 stars 417 forks source link

Width of the cell #54

Closed IgorLesnevskiy closed 7 years ago

IgorLesnevskiy commented 7 years ago

Hello. Can I somehow set the width of the cell? I have a cell with a large content in my html-table, but when I create XLSX - it has default cell width.

IgorLesnevskiy commented 7 years ago

I found this - http://stackoverflow.com/a/24466329, but is it right way?

st-sloth commented 7 years ago

Yup, for more info read https://github.com/protobi/js-xlsx#worksheet-object, section about ws['!cols']. In short, if you want to specify cell width in characters, use wch, if you want to specify cell width in pixels, use wpx. wch is preferable because this way you don't need to take the font typeface, size, etc. into account.