Read sheet hidden state - #50
Conversation
…igate whether the sheet state attribute can have more interesting values and whether adding this to SheetLink array is the right approach (seems fairly benign)
|
I had to change one unrelated fixture which turned out to have a hidden sheet 😺 |
|
Hmm.. I'm not getting this test failure for |
charts-and-images.xlsx has images in two sheets (Sheet1 background image5.png, Sheet2 drawing image6.png). The test asserts both appear in wb.images. Currently fails because context.images is shared mutable state across the Promise.all sheet processing loop — the last sheet to write wb.images wins, losing the other sheet's images.
|
Hmm.. it looks like there's actually a race condition because |
Process sheets sequentially instead of with Promise.all to eliminate shared-state races on context.images and context.drawingRels between await points. The async zip decompression operates on an in-memory buffer so parallelism provided no meaningful benefit. Also accumulate wb.images across sheets instead of overwriting.
Sequential sheet processing changes the order formulas are encountered, shifting formula indices. The formulas themselves are unchanged.
|
Processing the sheets sequentially required regenerating at least one more fixture json (tables.xslx), but all is passing now. Ready to discuss with you @borgar ... I'd be happy to change the approach and contribute any other desired improvements :-) |
|
That race is something I hit occasionally and have been intending to fix so I'm very happy you've cleaned that up. The approach is good, there is really no special advantage to parallel-running sheet conversion as the whole thing runs single threaded anyway. I'm sure hidden sheets we're working at some point but I must have regressed it, very good find! |
What
Read and set
hidden: 0 | 1 | 2fromworkbook > sheets > sheet[state]attribute (ECMA-376 - SpreadsheetML Reference section 18.2.19).Why
JSF supports it, we just had to read and map the states to the numerical representation (which matches the ST_SheetState definition, probably not by accident).
How
The parser has a
SheetLinkobject which is constructed when reading the workbook, collecting other information in the workbook sheet list. I added this property there, since that's where it is stored in the OOXML and a list of theseSheetLinkobjects is included inConversionContextfor handlers such as the worksheet handler which generates the JSFSheetobject for output.