Improve documentation regarding !ref #82
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#82
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?
when I create a sheet with 49 columns, it can only fill the first 20000 rows.
this is the code:
I ran your script against a really dumb template and it took roughly 2 minutes:
This is the generated file -- I warn you, it is big! The file is 262.5MB, which may explain why you are seeing issues? On a side note, it took more time to upload to dropbox than to generate the file.
Can you test the following:
Add the line with the comment to your script and run
Change the template so that it only has the header row, then run the script from above
Generate CSV instead of XLSX
Also, can you share the template?
Thank you , it's ok now with the line you added.
but can you explain the line you add in detail? I can't find any documents yet.
If this explanation makes sense, I'll add it to the readme:
The keys of a worksheet object are A-1 style references to the cell. For example, to get the cell object for B2, you would just access
worksheet.B2
orworksheet['B2']
.There are special keys (all starting with
!
) that correspond to sheet metadata. In particular,!ref
is the A-1 style cell range for the worksheet. For example, if the worksheet's range isA1:B2
, there are 4 cells (A1, B1, A2, B2). The output functions iterate through the rows and columns as specified in the range. The relevant code segment is in thewrite_ws_xml_data
function: https://github.com/SheetJS/js-xlsx/blob/master/bits/67_wsxml.js#L233I suspect your template had 20000 rows (or at least, that was the internal range storage). Your original script added cells but didn't update the range, which is why the output functions ignored them. If you want to see the range from your template, print it in the script:
awesome!
my template was saved from an xls file which had 20000 rows.
the codes are really long and complex, a more detailed guide is preferred, thanks again.
@lszhu heh if you think this is complex, the XLS parsing is much more intense
@lszhu added a short explanation of
!ref
in the README: https://github.com/SheetJS/js-xlsx#worksheet-objectI am trying to convert html table to xls and its getting converted to xsl successfully. However, I am facing issues with formula. Formula in the html table is not visible in xsl file, I just see a value at the place of formula.
Refering this example https://github.com/SheetJS/js-xlsx/blob/master/tests/write.js , it doesn't have any implementation for cell formula in xlsx spreadsheet I tried using cell.f = "=SUM(A1+B1)" for the cell C1 and cell.v as the summation value which was 3. But i didn't succeed. With the exported file, when opened in MS excel, the cell contained just the data and when selected, didn't show any formula which i assigned in f(x) field.
Can someone post me a example which actually uses the functions/property '.f' and 'cellFormula'
Will be very helpful. I just need a working example with static values.
@vikash52 did you solve the issue or find a way to solve it
@SheetJSDev
Sorry, but I can't understand this line:
sheet['!ref'] = "A1:AW100000"; // <-- i added this line to force it to write all of the cells
How did you get last range "AW100000"?
@Crusader4Christ AW100000 is the cell in the 49th column and 100000th row:
The original case from @lszhu used 100k rows and 49 columns, but since the original file specified a range of 20000 cells the rest were omitted.
The range needs to be changed since the writer won't include cells outside of the worksheet's range. The wiki includes some examples of how to update the range: https://github.com/SheetJS/js-xlsx/wiki/General-Utility-Functions
@reviewher So, if I need to work with OO Calc xlsx bigger than 65536 rows I should use
update_sheet_range(ws)
from https://github.com/SheetJS/js-xlsx/wiki/General-Utility-Functions?@Crusader4Christ if you don't know the bottom-right address,
update_sheet_range(ws)
scans all of the addresses and fixes the worksheet. That is not the most efficient approach but it works in generalIf you do know that address,
add_to_sheet(ws, bottom_right_cell_address)
is more efficient: