Skip to content

The config object

Lars Krieger edited this page Feb 23, 2017 · 1 revision

The config object

The config object is the object that the library uses to create your .xlsx file this file looks something like this:

TL;DR Config signatur

{
  filename: 'general-ledger-Q1',
  sheet: {
    data: [
      [{
        value: 'Income - Webshop',
        type: 'string'
      }, {
        value: 1000,
        type: 'number'
      }]
    ]
  }
}

Now lets dig in and explain the various keys.

Filename

{
  filename: 'general-ledger-Q1'
}

The file name key is the file name that your .xlsx file will be pre-pended with in the case above the file being downloaded would be named: general-ledger-Q1.xlsx the extention is some thing the too handles you just need to provide us the name.

Fallback: No fallback currently, missing the key would resolve as an error.

Sheet

The sheet key is an array of arrays. Each of the arrays defined within the sheet array represents a row in the excel sheet. Withing this row array a list of objects is placed and these objects needs to be normalized to the current implemented standards for the library, lets dig in and take each entity at a time:

sheet array

{
  sheet: []
}

This array is simply just the gate keeper where all your rows will be stored inside

Atonomy of the Row array and cell object

[{
  value: 'Label',
  type: 'string'
}, {
  value: 'Jan',
  type: 'string'
}, {
  value: 'Feb',
  type: 'string'
}, {
  value: 'Mar',
  type: 'string'
}],
[{
  value: 'Income Webshop',
  type: 'string'
}, {
  value: 10000,
  type: 'number'
}, {
  value: 35000,
  type: 'number'
}, {
  value: 2300,
  type: 'number'
}]

The arrays above would be placed into the sheet array and thean each of the arrays would act as one row withing the excel sheet it would look like this in the excel:

label Jan Feb Mar
Income webshop 10000 35000 2300

Cell object The cell object consists of two keys the value and the type, we use this to determin how the XML cell should be created, so if its a number the cell is then formatted as a number and vise versa with strings.

Suported types

  1. string - Default fallback if provided type is invalid
  2. number
Clone this wiki locally