Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
catamphetamine committed Feb 12, 2022
1 parent 134b4b1 commit c3d7008
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "read-excel-file",
"version": "5.2.27",
"version": "5.2.28",
"description": "Read small to medium `*.xlsx` files in a browser or Node.js. Parse to JSON with a strict schema.",
"module": "index.js",
"sideEffects": false,
Expand Down
7 changes: 5 additions & 2 deletions source/read/getData.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function getData(sheet, options) {
i++
}

// Fill in spreadsheet data structure.
// Fill in spreadsheet `data`.
// (this code implies that `cells` aren't necessarily sorted by row and column:
// maybe that's not correct, this piece code was initially copy-pasted
// from some other library that used `XPath`)
Expand All @@ -43,7 +43,10 @@ export default function getData(sheet, options) {
// const columnIndex = cell.column - leftTop.column
const rowIndex = cell.row - 1
const columnIndex = cell.column - 1
data[rowIndex][columnIndex] = cell.value
// Ignore the data in the cell if it's outside of the spreadsheet's "dimensions".
if (columnIndex < colsCount && rowIndex < rowsCount) {
data[rowIndex][columnIndex] = cell.value
}
}

// Fill in the row map.
Expand Down
9 changes: 7 additions & 2 deletions source/read/parseDimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ export default function parseDimensions(sheet) {
row,
column
}))
// When there's only a single cell on a sheet
// there can sometimes be just "A1" for the dimensions string.
// Sometimes there can be just a single cell as a spreadsheet's "dimensions".
// For example, the default "dimensions" in Apache POI library is "A1",
// meaning that only the first cell in the spreadsheet is used.
//
// A quote from Apache POI library:
// "Single cell ranges are formatted like single cell references (e.g. 'A1' instead of 'A1:A1')."
//
if (dimensions.length === 1) {
dimensions = [dimensions[0], dimensions[0]]
}
Expand Down

0 comments on commit c3d7008

Please sign in to comment.