sheetjs icon indicating copy to clipboard operation
sheetjs copied to clipboard

Edit worksheet that contain protected cell, cause the result cell filled with NAN

Open mgoku opened this issue 9 years ago • 3 comments

Hi,

I have a workbook (attached: items_2017-10-04.xlsx) that contain some protected cell inside the worksheet. I can read the protected cell, but can't edit it.

I use js-xlsx to manipulate some of the unprotected cell, and then save the workbook to a new file.

Everything work fine. The protected cell lost it's protected status, but it doesn't matter for my use case.

The only problem is, if the protected cell is empy, then the same cell at the new file will be filled with NaN text.

mgoku avatar Nov 20 '17 01:11 mgoku

The worksheet has many cells that are explicitly marked as number but have no data or formula. We'll push a fix shortly.

SheetJSDev avatar Nov 20 '17 01:11 SheetJSDev

Once the tests pass, we'll push the release to NPM.

The empty cells will not be generated by default when you read the workbook, so you may have to go back and create new cell objects if you intended to write to one of those cells. For example, G3 is empty. You can add it back by setting the worksheet G3 property to a cell:

workbook.Sheets['Sheet1']['G3'] = { t:'n', v:12345 };

You can force cell object generation by setting sheetStubs:true, but those will show up as stubs like { t: 'z' }, so you'd have to set the type to 'n' whenever you want to assign a value.

SheetJSDev avatar Nov 20 '17 02:11 SheetJSDev

Yes. Thank you.

mgoku avatar Nov 20 '17 06:11 mgoku