3.6.7 • Published 10 months ago

object-exporter v3.6.7

Weekly downloads
112
License
MIT
Repository
github
Last release
10 months ago

:dizzy: JavaScript Object to csv, xls, pdf, doc and DOM to html generator :dizzy:

Gitter chat Software License Standard - JavaScript Style Guide npm Downloads/week install size

A little JavaScript plugin to generate PDF, XLS, CSV and DOC from JavaScript Object or DOM element only from the frontend!

Demo

Please navigate to the following demo to test this library: Demo Page

Installation

You can download the latest version of ObjectExporter from the GitHub releases.

Configuration

In order use this library, follow the below steps:

  1. Download the latest release of the library from GitHub releases.

  2. Add the reference to the library in your HTML file:

<script src='<path>/objectexporter.min.js'></script>
  1. Paste the following to your JavaScript code and provide the required values as mentioned below:
objectExporter({
    exportable: <object>, // The dataset to be exported form an array of objects, it can also be the DOM name for exporting DOM to html
    type: <string>, // The type of exportable e.g. csv, xls or pdf
    headers: [{
        name: <string>, // Name of the field without space to be used internally
        alias: <string>, // The name of field which will be visualized in the export
        flex: <number> // An integer value which shows the relative width of this columns in comparison to the other columns
    }],
    fileName: <string>, // The name of the file which will be exported without the extension.
    headerStyle: <cssStyle>, // The style which needs to be applied to the column headers
    cellStyle: <cssStyle>, // The style which needs to be applied to each of the cells excluding the headers
    sheetName: <string>, // The sheet name containing the exported exportables
    documentTitle: <string>, // The document title which should be added to the printable
    documentTitleStyle: <cssStyle>, // The style which can be applied to the document header
    repeatHeader: <boolean>, // The table header repeat parameter
    columnSeparator: <char|string> // The expected column column separator in csv export
})

Aurguments description

ObjectExporter currently supports the below arguments:

ArgumentData TypeRequired?Default ValueAcceptable ValuesDescriptionApplicable to
exportablearray of objectsyesno default[{header1: value 1, header2: value 2},..., {headern: value n, headern+1: value n+1}]This is the array containing all of the objects which need to be exported.csv, xls, pdf and doc
typestringyesno defaultcsv, xls or pdfThis specifies the file type for generating the export.csv, xls, pdf and doc
headersarray or array of objects (1)yesno default[{name: 'fieldName1', alias: 'fieldAlias1', flex: flex1}, {name: 'fieldName2', alias: 'fieldAlias2', flex: flex2}, ..., {name: 'fieldNamen', alias: 'fieldAliasn', flex: flexn}]This specifies the headers for the exportable.csv, xls, pdf and doc
fileNamestringnoexportany acceptable string for the file nameThis specifies the name for the export.csv, xls, pdf and doc
headerStylestringnofont-size:16px; font-weight:bold;CSS styleThis specifies the style for the exported headers.xls, pdf and doc
cellStylestringnofont-size:14px;CSS styleThis specifies the style for the exported cells.xls, pdf and doc
sheetNamestringnoworksheetany stringThis specifies the sheet name for the excel file.xls
documentTitlestringnotest document titleany stringThis specifies the exportable file title.pdf and doc
documentTitleStylestringnocolor:red;any stringThis specifies the style for the document title.pdf and doc
repeatHeaderbooleannotrueany stringThis specifies the exportable header, whether it should be repeated accross various pages.pdf and doc
columnSeparatorchar/stringno,any string or characterThis specifies the column separator in csv exportcsv

(1) In versions older than 3.3.0, header was defined as an array and not an array of objects. However from version 3.3.0, the library is backward-comptible, therefore array or array of objects, both are accepted.

Contribution

Any contribution is always appreciated! :thumbsup: :thumbsup: :thumbsup:

In order to have this project installed in your development environment for the contribution purpose, follow the below steps:

  1. Fork this repository.

  2. Clone your forked repo. Then navigate to the downloaded folder and get the required packages for the library by:

npm install
  1. Build the library locally by:
npm run build
  1. Check test.html under the example folder to test the library:
npm install httpserver -g
httpserver

Then navigate to: http://localhost:8080/examples/example.html

  1. Now make your changes in the library.

  2. Keep checking example.html after any changes and make sure the library is working fine. In case you add new features, feel free to add/modify tests:

  3. Once you are done, check your code style by:

npm run test

In case there are issues, please resolve them before pushing the code.

  1. Well done! now push your code and make a pull request. :rocket:

License

ObjectExporter is available under the MIT license.

3.6.7

10 months ago

3.6.6

1 year ago

3.6.5

2 years ago

3.6.4

2 years ago

3.6.3

2 years ago

3.6.2

4 years ago

3.6.1

4 years ago

3.5.2

4 years ago

3.6.0

4 years ago

3.5.1

4 years ago

3.5.0

4 years ago

3.4.8

4 years ago

3.4.7

4 years ago

3.4.6

4 years ago

3.4.5

4 years ago

3.4.4

5 years ago

3.4.3

5 years ago

3.4.2

5 years ago

3.4.1

5 years ago

3.4.0

5 years ago

3.3.1

5 years ago

3.3.0

5 years ago

3.2.2

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.4

5 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago