Giter VIP home page Giter VIP logo

gharibi / jsobjexporter Goto Github PK

View Code? Open in Web Editor NEW
62.0 3.0 12.0 1.12 MB

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

Home Page: https://gharibi.github.io/JsObjExporter/examples/example.html

License: GNU General Public License v3.0

JavaScript 100.00%
javascript csv xls javascript-to-csv javascript-plugin javascript-to-xls es6-javascript js-object dom html

jsobjexporter's People

Contributors

farrukhsubhani avatar gharibi avatar mfsbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jsobjexporter's Issues

Can we save pdf directly without showing the print preview screen

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Add stylesheet support for html type

Is your feature request related to a problem? Please describe.
Currently exporting html type has no stylesheet support

Describe the solution you'd like
Add a parameter to support stylesheet from:

  1. url for a <link> element
  2. string for a <style> element

Describe alternatives you've considered
Include a <style> or <link> element inside the exportable DOM element, but according to the W3 specs <style> or <link> element must be included inside the <head> of the document

Additional context

Export to word (.doc file)

It will awesome to have an exporter for exporting elements/objects to Microsoft Word (.doc file).

In order to do so, the required schema for MS word has to be identified and accordingly the HTML element has to be passed to the schema. Then after downloading the Blob with .doc extension, the file will be compatible with MS word.

Security Alert on xls file opening

Describe the bug

Security alert on xls opening

To Reproduce
Steps to reproduce the behavior:

  1. Generate an xsl file.
  2. Open it with Excel (Max OS Excel for Mac 16.21.1)
  3. You got the screenshotted alert message

Expected behavior
No error message

Screenshots

capture d ecran 2019-01-30 a 14 22 43

Export to PDF

Currently object-exporter doesn't support export to PDF.

Just like export to CSV and XLS, it should also support export to PDF.

Supporting IE11

Currently object-exporter supports the export to CSV and XLS for Chrome version 71.0.3578.98, Safari version 12.0.2 (14606.3.4), FireFox version 64.0 and Opera version 57.0.3098.76. Let's say I have tested the library on the above platforms.

However IE11 is not supported for the both XLS and CSV exports. I had a quick look at the xls.js and the issue seem to be from here:

  let ctx = { worksheet: sheetName, table: dataset }
  let a = document.createElement('a')
  a.href = uri + base64(format(template, ctx))
  a.download = fileName + '.xls'
  a.click()

Maybe there are alternatives to the above code. Alternatively window.location could be used instead of a.click(), but the problem is, then the fileName cannot be set and moreover it will cause a redirection on the page.

html export fails on second attempt

Describe the bug
When you click on html export on example page it opens a browser print dialogue. If you cancel it and click on export button second time it gives an error in console and fails. It should open dialogue whenever export button is pressed.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://gharibi.github.io/JsObjExporter/examples/example.html'
  2. Click on 'Generate PDF under HTML to PDF'
  3. A print dialogue would open with Print and Cancel options.
  4. Click on Cancel
  5. Click on 'Generate PDF under HTML to PDF' again
  6. Open Console and see errors it would show Uncaught TypeError: Cannot read property 'remove' of null on document.getElementById("testFrame").remove()

Expected behavior
There should be no errors in console.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome
  • Version 79.0.3945.117 (Official Build) (64-bit)

Additional context
I have included the js file from cdn https://www.jsdelivr.com/package/npm/object-exporter

Advanced header handling

Currently the header attribute is supposed to be an array composed of the list of headers. In reality, header should have a field and an alias. This is quite important because the order of items in an object for the exportable are not necessarily the same and this cause a mismatch between the header and the rows.

The header has to be defined as follows:

headers: [{
    name: 'header_1',
    alias: 'header 1 alias',
    flex: 1
  },{
    name: 'header_2',
    alias: 'header 2 alias',
    flex: 1
  },
    . . . 
  {
    name: 'header_n',
    alias: 'header n alias',
    flex: 1
  }]

Since the current version of library is in production, it is not possible to simply shut the old versions down. In other words, there must be a backward-compatible solution. Which means it should be designed in a way, not to affect the current users.

XLS export doesn't work without the header attribute

When the API is called without providing the header attribute, the console logs an error and the export doesn't work:

Uncaught TypeError: Cannot read property 'length' of null
    at objectexporter.min.js:1
    at Object.export (objectexporter.min.js:1)
    at init (objectexporter.min.js:1)

The export should work even without providing the header attribute. In such cases, it should only printout the rows.

This was detected using object-exporter version Chrome version 3.2.1 and the error occured on:

  • Chrome version 71.0.3578.98
  • Safari version 12.0.2 (14606.3.4)

Export Multiple Tables

I have 2 different size tables. 2 rows of 10 cells and 2 rows of 26. Is it possible to export both tables in one document? Should I build the tables manually first? Any help would be appreciated.

Export to xls failed

Describe the bug
The export to xls failed. There are no data into the generated file.

To Reproduce

  1. Go to the demo website
  2. Click on "Generate XLS"
  3. Open the file

Screenshot
image

Note: I'm opening the file with LibreOffice

Override CSV Column Separator

Is your feature request related to a problem? Please describe.
When you export as CSV it always export as semicolon separataed values while some programs may not want this format and want to override it with comma separated values.

Describe the solution you'd like
It would be good to provide an option for CSV type to include cell separator.

Describe alternatives you've considered
We take the data out and run a manual process on it to replace all semicolons with comma but that is not ideal

Additional context
None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.