protobi / js-xlsx

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

Global styles for all worksheet and/or column? #129

Closed kaytrance closed 5 years ago

kaytrance commented 5 years ago

Is there a way to set a style that would be applied for whole sheet? For eaxmple in Excel one can select whole sheet and apply new font size, or select whole column and apply number formatting. If one do so in excel that is a different operation then applying new style to each and every cell, so it must not be per-cell format configuration.

I have not found a way to do similar thing using this package, so if there is such possibility can you please give some example how to achieve it.

pietersv commented 5 years ago

This library does not have concept of row, col or tab styles. I can imagine that for large books or ones you want users to be able to edit and return, that using only cell-level styling would lead to large file sizes or clumsy UX.

I tried this in Excel itself and see that Excel does have the concept of col and row and tab styles in the XML for each worksheet:

   <cols>
        <col min="1" max="2" width="10.83203125" style="1"/>
        <col min="3" max="3" width="10.83203125" style="2"/>
        <col min="4" max="16384" width="10.83203125" style="1"/>
    </cols>
    <sheetData>
        <row r="1" spans="1:6" s="3" customFormat="1" x14ac:dyDescent="0.2">

I can't tell where the tab-level styles are stored but they must be somewhere.
So theoretically it's possible to extend this library to add that. I imagine the commercial version of SheetJS would have that implemented.

kaytrance commented 5 years ago

Hello, thanks fot the answer, I might be able to add this functionality. Meanwhile per-cell I will apply per-cell styles.