protobi / js-xlsx

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

Empty cells with style aren't skipped anymore #8

Closed azukaar closed 9 years ago

azukaar commented 9 years ago

Fixing https://github.com/protobi/js-xlsx/issues/7

protobi commented 9 years ago

@azukaar Great catch, thanks!

The way the code is structured I'll make the change to the source file, which is located in bits/67_wsxml.js and that'll get compiled to ./xlsx.js.

Before I do that, can you send or describe a test case that I can use to (a) verify it fails now and (b) see it succeed after implementing? The comment suggests this was a feature that was dropped but I don't think I changed that function, so I just want to be careful to get it right.

azukaar commented 9 years ago

@protobi Sorry about the title may be the "anymore" might be misleading, I just meant that after the fix they aren't skipped anymore. To test a fail case, simply create a file with obvious pattern : image

Then open it and resave it using js-xlsx :

window.workbookTemplate = XLSX.read(e.target.result, {type:"binary" ,cellStyles : true, bookVBA : true});

Then

wbout = XLSX.write(window.workbookTemplate,
    bookType: 'xlsx'
    bookSST: false
    type: 'binary')
saveAs new Blob([  s2ab(wbout)  ], type: 'application/octet-stream'), "test.xlsx"

Finally reopen the result in Excel and it will be : image

This is actually a real issue for a lot of Excel file, for exemple : image

Here, those strokes will disappear no matter what, because the inset cell will always be empty even after the report will be filled. Oh also, sorry about fixing the bad file, I wasn't quite confident about the structure of the project !

protobi commented 9 years ago

@azukaar Very helpful. Your changes are made and addressed under issue #7