Generate CSV, PDF And XLS Files From JS Objects – JsObjExporter

Category: Javascript | January 12, 2019
Author: gharibi
Views Total: 97
Official Page: Go to website
Last Update: January 12, 2019
License: MIT

Preview:

Generate CSV, PDF And XLS Files From JS Objects – JsObjExporter

Description:

JsObjExporter is a lightweight and fast JavaScript library used to dynamically generate CSV, XLS, and PDF files from an array of JavaScript objects.

How to use it:

Download the library and load the JavaScript file objectexporter.min.js in the page.

<script src='objectexporter.min.js'></script>

Or from a CDN.

<script src='https://unpkg.com/[email protected]/dist/objectexporter.min.js'></script>

Prepare your data.

const myData = [{
        col1: value 1, 
        col2: value 2
      },{
        col 3: value 3, 
        col 4: value 4
      },{
        col 5: value 6, 
        col 5: value 6
}]

Export the data you provide to a CSV, XLS or PSF file.

objectExporter({
  exportable: myData,
  type: 'xls' // or 'csv', 'pdf'
})

Customize the header for CSV export.

objectExporter({
  exportable: myData,
  type: 'csv',
  headers: [header 1, header 2, ..., header n]
})

Customize the file name of the generated CSV, XLS or PSF file.

objectExporter({
  exportable: myData,
  type: 'csv',
  fileName: 'export'
})

Customize the styles.

objectExporter({
  exportable: myData,
  type: 'csv',
  headerStyle: 'font-size:16px; font-weight:bold;',
  cellStyle: 'font-size:14px;'
})

Customize the sheet name for XLS/PDF export.

objectExporter({
  exportable: myData,
  type: 'xls',
  sheetName: 'yourname' 
})

Changelog:

01/12/2019

  • Added the support for headers as array of objects.

01/11/2019

  • Updated the version considering the new functionality for generating PDF

You Might Be Interested In:

Leave a Reply