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

Category: Javascript | July 16, 2023
Author:gharibi
Views Total:109 views
Official Page:Go to website
Last Update:July 16, 2023
License:MIT

Preview:

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

Description:

JsObjExporter is a lightweight and fast JavaScript library used to dynamically generate CSV, XLS, DOC, 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/obje[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' // csv, xls, pdf and doc
})

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 header and cell styles. Applicable to xls, pdf and doc.

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

Customize the sheet name for XLS export.

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

Customize the document title for pdf and doc export.

objectExporter({
  exportable: myData,
  type: 'pdf',
  documentTitle: 'Title',
  documentTitleStyle: 'color: red'
})

Determine whether or not to repeat headers across various pages. Applicable to pdf and doc.

objectExporter({
  exportable: myData,
  type: 'pdf',
  repeatHeader: true
})

Specify the column separator in csv export.

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

Changelog:

v3.6.7 (07/16/2022)

  • Updated the underlying dev dependencies

v3.6.4 (09/18/2022)

  • Updated the underlying dev dependencies

v3.6.4 (01/13/2022)

  • Resovled the issue with html tags in table cell

v3.6.3 (01/13/2022)

  • updated the underlying dependencies

v3.6.1 (11/01/2020)

  • Resolved the issue with XLS export for IE and Edge

v3.6.0 (09/21/2020)

  • Resolved the issue with the wrong column headers in IE.

v3.5.1 (05/29/2020)

  • Updated the minified version of the library

v3.5.0 (03/10/2020)

  • Added ‘columnSeparator: <char|string>’ as a new property for CSV exports to define the desired column separator.
  • Resolved the issue in printing pdf using the latest version of FireFox.

v3.4.6 (01/13/2020)

  • Supporting export from DOM objects to PDF

v3.4.5 (11/22/2019)

  • Resolved the issue with wrong csv format in case there is no data available for the cell.

v3.4.4 (10/04/2019)

  • Added the support for repeating the table headers.

v3.4.3 (09/18/2019)

  • Supporting title and title style for the XLS exportable

v3.4.1 (01/28/2019)

  • Minor updates for the download mechanism.

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