Excel File Import

Loading data from Excel into SpreadSheet

You can easily import data from an Excel file into SpreadSheet.

Pay attention that SpreadSheet allows importing data, formulas and spans from Excel, while styles and sizes of cells are not imported.

To load data from Excel into SpreadSheet, you can choose one of the ways below:

1) specifying the necessary file in the SpreadSheet constructor with the help of the url parameter:

    url: "binary->../common/test.xlsx",

The notation "binary->../common/test.xlsx" allows loading compiled files from the computer and get their content.

The "excel" datatype allows parsing the content of a binary file and getting it in the form necessary for SpreadSheet.

2) calling the load method:

$$("ssheet").load("binary->../common/test.xlsx", "excel");

The parameters are:

  • file - (string) the name of the file to load
  • datatype - (string) data type (should be "excel" here)

3) using the parse method to load data to the component:

{ view:"uploader", value:"Load from Excel file", on:{
    onBeforeFileAdd: function(upload){
        $$("ssheet").parse(upload.file, "excel");
        return false;

Parameters of the parse method are the following:

  • file - (object) uploaded file object
  • datatype - (string) data type (should be "excel" here)

Import settings

SpreadSheet allows importing a range of settings from an Excel file. Styles, column width and row heights are imported by default. You can also import:

  • math formulas

You need to set the math:true property in the SpreadSheed configuration, if it is disabled by some reason.

    view: "spreadsheet",
    data: base_data,
    math: true

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

  • column and row spans

To import spans, you should set the spans:true property in the SpreadSheet config:

    view: "spreadsheet",
    data: base_data,
    spans: true
  • sheets

By default, Spreadsheet shows only the first imported sheet. In order to browse all of them, you need to set either the bottombar:true or toolbar:"full" properties in the SpreadSheet configuration:

    data: base_data,
    toolbar: "full" // or bottombar:true
  • dates

SpreadSheet allows importing Webix-formatted dates from an Excel file.

Customizing Imported Data

You can customize the presentation of the loaded data: set the name of the sheet and control the number of the loaded rows.

    url: "binary->../common/test.xlsx@Data[0-10]",

The string value of the url property binary->files/data.xlsx@Data[1-10]" includes the following parts:

  • binary - the name of the proxy object
  • ../common/test.xlsx - path to the Excel file
  • @ - optional, the delimiter that detaches the link from its parameters (can be omitted together with parameters)
  • Data - optional, the name of the Excel sheet to render
  • [1-10] - optional, the rows that should be rendered in the viewer

To render rows starting from a certain row, you can set the rows array as [8-].

Related sample:  Import from Excel

Importing Data Offline

The dependencies which are necessary to import data from Excel files into SpreadSheet are generally taken from Webix CDN online catalog. If you need to import data offline, you should complete the following steps:

If you use Webix version 5.0 or later, use the file xlsx.core.styles.min.js.
In case of a version earlier than 5.0, choose the file xlsx.core.min.js.

  • rename the folder to "extras" and move it to the desired directory
  • set the path to the local CDN repository as:
webix.cdn = "/local_folder";

Note that specifying the path to the local CDN repository has some peculiarities:

1) in case you set the path relative to the current page, it should be specified as:

webix.cdn = "../../../../local_folder";

2) the absolute path to the repository should be specified as follows:

webix.cdn = "http://localhost/local_folder";
Back to top
If you have not checked yet, be sure to visit site of our main product Webix javascript ui components library and page of javascript spreadshee product.