Click here to Skip to main content
15,921,837 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a html file.
Firstly, i need to create a save button using JavaScript.
When i will press save button it will save the content of div into an excel or pdf.

Can anyone provide the code for this purpose?
Posted

1 solution

For Excel


Refer - how to generate Excel through Javascript[^].
Quote:
You can generate whatever you like, but the question is - how are you going to present it to the user? If your JS runs in the browser, you won't be able to make a save-as dialog box or even open it in the same window. Not unless you use some ActiveX controls, but that's an IE-only solution which will also give the user a few confirmation prompts before it starts to work.

You can also try Excel Builder(.js)[^].

For PDF


Refer - Generating PDF files with Javascript[^].
Quote:

I've just written a library called jsPDF which generates PDFs using Javascript alone. It's still very young, and I'll be adding features and bug fixes soon. Also got a few ideas for workarounds in browsers that do not support Data URIs. It's licensed under a liberal MIT license.


I came across this question before I started writing it and thought I'd come back and let you know :)


Generate PDFs in Javascript


 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900