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

Empty cells (for styling) #59

Open jkurei opened 7 years ago

jkurei commented 7 years ago

Hi. First of all, thanks a lot for this project, it's been immensely useful.

I've been writing a new feature to write a XLSX file, with a particular style, and I've stumbled upon a (admittedly minor) problem. This document has some rows that are left empty, but nonetheless need to be styled (to have a matching background, for instance).

To style the cell, of course, it has to exist, but I've been unable to create cells with no content (like having .v set to null) and xlsx won't allow it.

I've resorted to giving it an empty string as value (""), but this creates a new problem: Excel doesn't see it as a truly empty cell, and won't allow the previous cell to override it, which is already making my users complain. Here's an example:

screen shot 2017-02-28 at 18 19 48

That third row has a cell with a long text that should take on the next cell, which is empty. This can be fixed just by selecting and deleting that next cell, and it will keep it style while being truly empty, but I want to make my users edit this file as little as posible.

What would be the best solution? Any way to allow the styling of cells that don't exist? Or would it be best to make XLSX able to hold cells with really no value (which would have to be raised to the original project, I guess)?