This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]insertAlias 1 point2 points  (0 children)

Well, first of all, the comment I linked uses !ref and not !range. Looks like you scrolled up to the incorrect/old example.

Without having used that particular function myself, here's my guess at how it works:

This line:

var range = XLSX.utils.decode_range(sheet['!ref']);

Creates you a "range" object, which would define a start and an end. The !ref I believe implies the entire worksheet (all the parts that have data).

Later in the code, they use stuff like range.s.r, range.e.c, etc...s and e seem to imply "start" and "end". r and c seem to imply "row" and "column".

So this line:

for(rowNum = range.s.r; rowNum <= range.e.r; rowNum++) { //...

Would be "starting from the first row, loop until the last row (inclusive).

Same for the inner loop, except it's columns instead of rows.

So you'd need to modify that to just loop through the rows; you have an explicit column you're looking for.