Fomulas not showing as string/text in a cell #2948
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#2948
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?
I am using SheetJs + X-spreadsheet,.
/* convert to x-spreadsheet form */
var data = stox(wb);
/* update x-spreadsheet */
xspr.loadData(data);
The data sometimes does not have the unrecognized fomulas as text in a cell and sometimes does. May I ask why is that?
I would like to have the fomulas in the "data" so that when I export it to excel file, I will write them back to the json data.
I am currently doing is that record the row and column index of a fomula and replce the cell with empty string so that the file can be loaded in X-spreadsheet. Then when I export it, I write them back to the json data for excel file.
The unminified version is available at https://cdn.sheetjs.com/xspreadsheet/xlsxspread.js (we'll eventually make a repo for this)
When importing data into the grid, x-spreadsheet checks the cell text and assumes text starting with
=
represents a formula. . The connector library checks each cell and passes the formula if the cell has a formula (and passing the formatted value if the cell does not have a formula).When exporting data out of the grid, the connector library performs a value parsing step similar to the logic for reading CSV files. If the cell text is
true
orfalse
, then the connector emits boolean cells (typeb
). If the cell text starts with=
, the connector library assumes the text represents the formula. Numeric values are guessed by converting strings to numbers and testing if the cell value isNaN
The overarching issue is that x-spreadsheet provides no way to sideload formulae.
If you think the converter should behave differently, please let us know and we can consider adding an option or changing the default behavior.
Hi @sheetjs
Thanks for the promt reply. I have found the "issue".
I copied the demo code and have it running in my local.
My excel file is generated by an API and saved to my local. If I use the demo above to load the file directly without any editing, I won't be able to see fomulas as text from the output of stox. But if I open it and do some editing, even just remove a single character and save it. I will be able to see the fomulas outputed by stox.
Please see my attached screenshots.
Can you try changing the following in the demo:
Line 74 (currently
process_wb(XLSX.read(data));
):Line 112 (currently
.then(function(ab) { process_wb(XLSX.read(ab)); });
):Line 120 (currently
XLSX.writeFile(new_wb, 'sheetjs.xlsx', {});
):If this works, we'll update the demo. If not, please share a sample file and we can take a closer look.
I just tried it and it worked, I can see the formulas are in the workbook object.
But the data returned from
stox
still does not have cells with formulas.See my attached screenshots.
Hi @sheetjs
May I ask if you had a chance to try it out?
Thanks a lot
@sheetjs is it not easy to fix?