Export To Excel Using JavaScript

Export to excel sheet using client side Javascript

Introduction:

Various binaries and support libraries are present to help us export grids / tables / data to excel sheets, but the same export handling at client side is a tough nut to crack. This plugin helps you achieve that, thereby providing advance features as well.

Features:

  1. Supported on all jQuery compliant browsers.
  2. Supports both DOM / JSON / XML / JqGrid data objects.
  3. Feature to provide custom header to a column.
  4. Feature to provide custom width to a column.
  5. Feature to hide a column in exported excel sheet.
  6. Feature to bind column with a datafield in data object.
  7. Feature to specify a download file name using returnUri feature.

Documentation:

  1. Column Properties
    S.No.Property NameTypeDescription
    1headertextstringThis is the custom header text to be specified for a column.
    2datatypestringThis is the data type of the column. For now, provide “string” in all cases.
    3datafieldbooleanThis is the datafield from the data object to be mapped.
    4ishiddenbooleanSpecifies whether to hide the column at in the exported excel.
    5widthenumSpecifies the width of the column in the exported excel.
  2. Settings
    1. Container Id: A string Id of the container. Div id in case of Json, XML and JqGrid, and table id in case of Table data type.
    2. DataType: Enumerator data type.
    3. DataSet: DataObject to be specified in case of Json, XML and JqGrid Data.
    4. Columns: Array of Columns to be displayed on the excel sheet.
    5. ReturnUri: (Boolen), this is true in case where user needs to specify a different download file name and utilize the data file URI.
    6. Worksheet Name: The name of the worksheet in the excel sheet.
    7. Encoding: Specifies the character encoding format.
  3. DataType

    The following data types are allowed:

    1. Table
    2. Json
    3. Xml
    4. JqGrid

Important links:

  1. Code
  2. Bugs / Feature Request

Supported Browsers:

  1. Chrome, supported in all versions
  2. Firefox, supported in all versions
  3. Opera, supported since 7.2
  4. Safari, supported in all versions
  5. Internet Explorer, not compatible.

Limitations:

  1. Data URI’s have size limitations for different browsers.
  2. Not supported on IE.

How to use:

  1. Run code from Github:
    1. Run “npm install”
    2. Run “bower install”
    3. Run “index.html”
  2. Implement in your project:
    1. Run “bower install excelexportjs”
    2. Add “bower_components/excelexportjs/dist/jquery.techbytarun.excelexportjs.js” to your page.
Facebook Comments