XLSX parsing #753

Closed
opened 2017-07-30 08:11:50 +00:00 by louiepiol · 2 comments
louiepiol commented 2017-07-30 08:11:50 +00:00 (Migrated from github.com)

Question about parsing a excel file.
Can I get the value of a cell through a loop by column cell.
A1 + 14 = O1
A1 has 13 column difference to O1.

var workbook = XLSX.read(data, { type: 'binary' });
var worksheet = workbook.Sheets['Sheetname'];
var value = worksheet['A1'...'O1'];

Is there any way to make it possible?

Question about parsing a excel file. Can I get the value of a cell through a loop by column cell. `A1 + 14 = O1` A1 has 13 column difference to O1. > var workbook = XLSX.read(data, { type: 'binary' }); > var worksheet = workbook.Sheets['Sheetname']; > var value = worksheet['A1'...'O1']; Is there any way to make it possible?
harmon25 commented 2017-08-01 19:01:55 +00:00 (Migrated from github.com)

Could decode, perform calculation, and re-encode a cell to accomplish this.

let A1 = XLSX.utils.decode_cell("A1");
let O1 = XLSX.utils.encode_cell({ c: A1.c + 14, r: A1.r });
console.log(O1); // "O1"

Could decode, perform calculation, and re-encode a cell to accomplish this. ```js let A1 = XLSX.utils.decode_cell("A1"); let O1 = XLSX.utils.encode_cell({ c: A1.c + 14, r: A1.r }); console.log(O1); // "O1" ```
reviewher commented 2017-10-03 06:55:04 +00:00 (Migrated from github.com)

@louiepiol you have to manually expand the range. In this case, you can do something like:

var range_string = "A1:O1";
var range = XLSX.utils.decode_range(range_string);
for(var C = range.s.c; C <= range.e.c; ++C) {
  var addr = {r:0, c:C}; // row and col are 0-indexed, so r:0 is Row 1 
  var addr_str = XLSX.utils.encode_cell(addr);
  var cell = worksheet[addr_str];
  // do something with cell here
}
@louiepiol you have to manually expand the range. In this case, you can do something like: ```js var range_string = "A1:O1"; var range = XLSX.utils.decode_range(range_string); for(var C = range.s.c; C <= range.e.c; ++C) { var addr = {r:0, c:C}; // row and col are 0-indexed, so r:0 is Row 1 var addr_str = XLSX.utils.encode_cell(addr); var cell = worksheet[addr_str]; // do something with cell here } ```
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#753
No description provided.