I am trying to get my html table in a MS Excel document and I have tried many examples from here and internet but most of them didn't work. Mostly I can download a .xls file and when excel opens that file it comes nothing (not even standard Excel grid). And when I open the .xls files with Notepad, I can see that file actually holds values.
Most of the comments in previous questions were telling they work but these question dates are also little bit old and I can't tell if I am having version problems.
For example Javascript to export html table to Excel , I can download an Excel file but can't see values in it.
Also this DataTables example work well for me but I don't need all the stuff they provide like searching and listing.
Please let me know if any of you had such trouble and how did you solve them.
You have a solution (by your own admission): DataTables. Any features you don't need can be turned off or just not used.
Related
I am now working on an Angular application that modifies an existing excel file (.xls) uploaded by the user then save the modified file in the local. The point is this excel file contains some fancy styling and a lot of macros, with several buttons which contains a lot of VBA code (I am not excel expert, sorry if I mistake their name).
I have tried several existing solutions till now:
xlsx
exceljs
For the first solution, I can only access the community version which basically ignores all these information: style, macro/VBA.
For the second solution, it can preserve almost every style but ignores the macro/VBA.
Except for these solutions, I haven't found any working solution. I turn to the community for help, any kind of solution, even a little hint would be appreciated!
I'm a newbie to AngularJS and using AngularJS for my web app.
On one page of my web app, I'm fetching data from database and displaying in a table. The data is in JSON format. And, since it contains multiple entries of the same type, it's an array.
I want to provide a Download button to the user and a radio button with the options of .pdf and .docx.
The User will select one of the file formats and click on Download button in order to download the data displayed in table into the selected file format on his/her local machine.
How to achieve it? Can someone please guide me in this regard?
Since the code to fetch and display data in table is too big that's why I haven't given any code snippet here.
If you want I can provide you the same.
If you can explain with some completely working examples for both file formats(.docx and .pdf) in AngularJS it would be really really great to me and other buddies.
Thanks.
There are some few good resources. I use https://mozilla.github.io/pdf.js/ for PDF and https://github.com/evidenceprime/html-docx-js for docx though it needs some manipulations.
Try these that I could find. This is not supposed to be a list of options but each of them have different functionalities. But it surely does not make sense making your own port for these.
PDF
http://pdfkit.org/ for extended PDF formatting
https://github.com/tuckerjt07/pdfmake allows for PDF formatting
https://github.com/Prashanth-Nelli/jsPdfTablePlugin Straight forward simple usage
http://github.com/MrRio/jsPDF frequently used
DOCx
http://github.com/MrRio/DOCX.js
https://github.com/evidenceprime/html-docx-js
Angular UI-Grid has implemented PDF/CSV Export from grid.
Please refer UI-Grid Export Data
They are using Pdfmake to generate PDF of exported data.
just google for a javascript library that enable you to easily convert your json data to PDF, something like http://github.com/MrRio/jsPDF – Naigel Mar 29 at 9:52
the same person also created this http://github.com/MrRio/DOCX.js – jcubic Mar 29 at 9:54
I'd agree, there's nothing gained from building it yourself unless it's a specialised system, but yours sounds like a very standard way of doing things so it would be far better to use a pre-made system and not waste the time that could be spent better developing the bespoke parts of the system.
I am given to understand that there are ways to generate Excel files from Classic ASP, by means of basically making an HTML table and calling it a spreadsheet. The output, however, doesn't seem to be quite what I'm looking for -- when opened in Excel, it looks like an HTML page with a table instead of a normal spreadsheet. So I'm not sure I want to go with that, though I'm open to being sold on the possibility.
Due to reasons, I'm working with a website that runs ASP Classic using JavaScript, which appears to have been very uncommon even back when ASP Classic was cutting-edge. I understand there are also means of generating Excel files in JavaScript, but they seem to be for more typical environments like a browser or Node.js; I think #include only works with other ASP files.
I would just output a CSV file, except that I have to be able to include images in the spreadsheet.
The html table method works well if the table tag is the only tag in the body of the html, and you don't have any specific styling for the table cells that will conflict with what Excel would normally do.
What you might consider is something called SpreadsheetML, which is an xml schema that Excel will understand for defining a spreadsheet. This is different than the xml format used for the newer Office documents. Take a look here for an example:
Generating an Excel file in ASP.NET
Also, the accepted answer in that same question will cover some of your other options. It's targeted for ASP.Net rather than classic ASP, but a lot of the material still applies.
If you were using VBScript ASP then you would simply need to add the following lines, before your opening <table> tag
<%
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=yourspreadsheetname.xls"
%>
To convert these two lines into server side JS I think it would just be a case of adding a semicolon at the end of each line.
Javascript runs on the browser, so it doesn´t matter if your backend is Classic ASP or any other.
As of Excel 2007+ the XLSX format is just a ZIP containing a set of XML files following the [Office Open XML specification][1].
This can definetely been done in JavaScript, and there are a bunch of libraries that provide this functionality. Just Google them.
I'm looking into potentially building code for NetSuite to read the contents of an Excel file (XLS or XLSX) within JavaScript in order to process the data. I can do this just fine with a CSV file, but I'd like to expand capabilities to read Excel worksheets.
I've seen a variety of scripts to read in Excel files, but they all seem to revolve around a dependency of Internet Explorer, and none of them seem to offer a solution on how to get the used columns and rows. They assume you already know this information ahead of time. NetSuite being what it is, these solutions don't really work, and you have to grab the base64 encoded contents of the file object stored in the system. This isn't an issue with CSV files, it's still just plain text.
I've done some testing and found that I get different results when trying to decode the string (I get something from XLS, but nothing from XLSX). I was wondering if anyone has tried and succeeded and reading data from these files formats in a NetSuite JavaScript implementation. If there's no good way, then I'll just have to force use of CSV, but I'd like to have some flexibility.
Essentially, you are asking for a javascript implementation of XLS and XLSX parsers. It is incredibly difficult, mostly due to the nature of the data format and the sheer amount of parsing required to get basic data).
I have built a basic version:
http://oss.sheetjs.com/js-xls/ (xls)
http://oss.sheetjs.com/js-xlsx/ (xlsx)
I figured out how to generate Excel spreadsheets that open with newer versions of Excel, but it turns out many clients are using old versions of Excel. So I need to figure out how to generate old Excel files.
I used this to generate the files:
http://en.wikipedia.org/wiki/Microsoft_Excel#XML_Spreadsheet
I don't need anything too complex, I just need to insert simple rows and columns. I can't find anything that shows me the old format though (I'm hoping it's at least something human-readable). I'm not even entirely sure which versions of Excel they are using. Is there some way I can generate an Excel document that will work for older versions?
I'd prefer if there was something that let me generate the file myself, but a library would be fine too. I'm using JS and Node, and all I can find is node-excel, which claims to have the first version done in March, and I assume will have the same problem as the simple program I wrote (not working with versions of Excel prior to 2002).
Thanks for reading.