Skip to content

Formatting xlsx from JSON

Rowan Smith edited this page Dec 20, 2017 · 5 revisions

Formatting Rules

Workbook / Worksheet / Cell Object Description

This will look at js-xlsx formatting and how to do it in node-xlsx

js-xlsx conforms to the Common Spreadsheet Format (CSF):

General Structures

Cell address objects are stored as {c:C, r:R} where C and R are 0-indexed column and row numbers, respectively. For example, the cell address B5 is represented by the object {c:1, r:4}.

Cell range objects are stored as {s:S, e:E} where S is the first cell and E is the last cell in the range. The ranges are inclusive. For example, the range A3:B7 is represented by the object {s:{c:0, r:2}, e:{c:1, r:6}}. Utils use the following pattern to walk each of the cells in a range:

for(var R = range.s.r; R <= range.e.r; ++R) {  
  for(var C = range.s.c; C <= range.e.c; ++C) {  
    var cell_address = {c:C, r:R};  
  }  
}