How to access Row Object and set properties #81
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#81
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi All,
thanks for creating such a great project.
I tried to figure out how its possible to set some Row Properties when creating a XLSX Spreadsheet - i need to set the property "hidden" on the Row to hide it.
How is the best practice to do this?
Thanks a lot,
Bernhard
@neversaid Row properties are not parsed or written at the moment. It is on the roadmap :)
If you are interested in adding it now, the process is fairly straightforward. The line that writes the row tag on output is:
https://github.com/SheetJS/js-xlsx/blob/master/bits/67_wsxml.js#L244
To make rows hidden, add
hidden:1
to the object. For example, to hide all rows:I would stick the metadata in an array
!rows
to the worksheet:To set row
N
to be hidden:Then the write_ws_xml_data function would check at the end of each row:
@SheetJSDev
Thanks a lot - that helps - just added the function to save Formulas on my local git checkout.
If you want i can commit, would appreciate to work on your team.
TIA
Bernhard
Contributions are welcome :)
If you want to send a contribution, can you also add similar logic to the parser? The code is in the same file, and there are two additions to the code:
https://github.com/SheetJS/js-xlsx/blob/master/bits/67_wsxml.js#L152
Just before the for-loop, add an empty array to the worksheet:
Later in the code,
tag
is an object corresponding to therow
tag in the xml:https://github.com/SheetJS/js-xlsx/blob/master/bits/67_wsxml.js#L158
Right after that, save the tag in the array:
We'd also need some tests. For now, keep it simple: generate a file, read it, and check if the hidden property is preserved. As an example roundtrip test, https://github.com/SheetJS/js-xlsx/blob/master/test.js#L400 writes the workbook in memory as a nodejs Buffer and then reads it.