Data Export

SpreadSheet provides the possibility to export data to Excel, PDF, CSV and PNG formats.

For any of these formats, you need to initialize a SpreadSheet first:

webix.ui({
    id:"ss1",
    view:"spreadsheet",
    data: sheet1_data
});

Then call the corresponding method: toPDF, toPNG or toExcel to export data from SpreadSheet into the file of the necessary format:

for Excel:

webix.toExcel("ss1");

for PDF:

webix.toPDF("ss1");

for PNG:

webix.toPNG("ss1");

for CSV:

webix.toCSV("ss1");

By default, SpreadSheet data is exported to any format with the following settings:

  • header:false - the sheet header is not exported
  • rawValues:true - all dataset columns are exported
  • spans:true - column and row spans are exported
  • styles:true - styles are exported
  • math:true - math formulas are exported
  • ignore:{rowId:true} - the column with row ids isn't exported

You can change this behavior by specifying the desired settings as object in the second parameter of the export methods. For example:

webix.toExcel("ss1",options);

Related sample:  Export to .xlsx, .pdf and .png

Export to Excel Settings

SpreadSheet allows exporting a range of settings into an Excel file.

  • math formulas

You need to set the math:true property in the second parameter of the toExcel method.

webix.toExcel($$("ss1"),{ math:true});

Spreadsheet supports sheet-specific named ranges only, global named ranges won't be exported.

  • cell styles

The styles are exported by default. If they are not, set the styles option to true in the second parameter of the toExcel method.

webix.toExcel($$("ss1"),{ styles:true});
  • column and row spans

The spans are exported by default. Otherwise, set the spans:true property in the second parameter of the toExcel method:

webix.toExcel($$("ss1"),{ spans:true});
  • row heights This setting is regulated by the heights option, which is set to false by default and can take the following values:
    • true - to export only custom row heights (different from the default rowHeight);
    • "all" - to export both custom and default row heights;
    • false - default, row heights are not exported.
webix.toExcel($$("ss1"), {
   heights:true
});

In case the styles:true option is set, the heights option is automatically set to "all".

  • multiple sheets

By default, Spreadsheet exports the currently active sheet to an Excel file. You can have three more possible options:

1) to export all the sheets, set the sheets:true option in the second parameter of the toExcel method:

webix.toExcel($$("ss1"),{ sheets:true});

2) to export separate sheets, set an array with sheets ids as a value of the sheets option:

webix.toExcel($$("ss1"),{sheets:["s1","s2"]});

3) to export a certain sheet, set its id as a value of the sheets option:

webix.toExcel($$("ss1"),{sheets:"s2"});
  • the header of a sheet

By default the header of a sheet is not exported. To export the content of a header, you need to use the header option and set it to true:

webix.toExcel($$("ss1"), {
   header:true
});

Exporting Data Offline

You can export SpreadSheet data offline. To enable this possibility, you should follow the common way for all data components.

Back to top
If you have not checked yet, be sure to visit site of our main product Webix javascript ui framework and page of web based spreadsheet product.