xtos throws TypeError when first rows have no columns #2656
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#2656
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?
In file sheetjs/demos/xspreadsheet/xlsxspread.js function xtos line 137 will throw an error on minCoord.r when the spreadsheet passed in has the first couple rows empty (no columns) and below these empty rows has real data.
This is caused by xtos line 81 setting minCoord and maxCoord so their initial value is undefined then line 82 runs a forEach loop on all the columns in that row. The values of minCoord and maxCoord should be set in the forEach loop. However, if there are no columns in that row minCoord and maxCoord's values are never set and so calling minCoord.r on line 137 fails and produces an error.
This can be simplified by anchoring the starting point to A1. If it works please feel free to send a PR
This is approximately what I did to fix it on my local machine but I can't submit a PR because of my employer's policy on outside work. I would have to get it approved first.
Updated the public demo https://oss.sheetjs.com/sheetjs/x-spreadsheet.html