Skip to content

Instantly share code, notes, and snippets.

@TuvianNavy
Last active May 30, 2020 04:01
Show Gist options
  • Select an option

  • Save TuvianNavy/95926ba9484442113b14a2a91408a3f9 to your computer and use it in GitHub Desktop.

Select an option

Save TuvianNavy/95926ba9484442113b14a2a91408a3f9 to your computer and use it in GitHub Desktop.
JavaScript XLSX (requires SheetJS)
var min_col = 1; // 0-indexed colnum (it means "B")
var min_row = 11; // 0-indexed rownum (it means "12")
var max_col; // 0-indexed colnum
var max_row; // 0-indexed rownum
XLSX = require('xlsx');
Book = XLSX.readFile(Sample_XLSX_Path);
Sheet1 = Book.Sheets[Sample_Sheet];
var range = XLSX.utils.decode_range(Sheet1['!ref']);
max_col = range.e.c;
max_row = range.e.r;
for(var row = min_row; row <= max_row; row++) {
var buf = '';
for(var col = min_col; col <= max_col; col++) {
var celladdr = XLSX.utils.encode_col(col) + XLSX.utils.encode_row(row)
var cell = Sheet1[celladdr];
if (col !== min_col) { buf += ' ' };
if (cell === undefined) {
buf += 'null'
} else {
buf += cell['v']
}
}
console.log(buf)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment