Using cell objects in json_to_sheet? #1168
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#1168
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
Thanks for this great library and all your hard work – it's really impressive.
I'm trying to export some database records into Excel. I've used
json_to_sheet()
to output something basic, but I wanted to add a=HYPERLINK()
formula for one cell.Reading the docs, I can see that I need a
.f
or.l
key on the relevant cell object to use a formula. This doesn't work when I usejson_to_sheet()
though, eg:In the outputted sheet, both rows have a blank "homepage" column (the others are fine).
I guess this means the import functions don't allow cell objects. Is my only option here to import the JSON and then traverse the sheet and find my homepage values and manipulate the cell objects from there? It would be great if I could just set these at import time (as outlined above) if at all possible!
As it is currently shaped, cell objects are not passed through. Fortunately its a simple fix!
https://github.com/SheetJS/js-xlsx/blob/master/bits/90_utils.js#L199-L207 is the block that builds the cell to add. It could be changed as follows:
You'd still have to make an actual cell object (with
t:'n'
), but that's straightforward.We'll make that change in the next release (or you can send a PR :)
Done! Check out https://github.com/SheetJS/js-xlsx/pull/1169
Also, with regards to "You'd still have to make an actual cell object", you mean when I'm actually calling
json_to_sheet
, right? (eg. see my updated example code in the above PR)