How can I generate an Excel spreadsheet in JavaScript-based Classic ASP? - javascript

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.

Related

Modify existing excel file with macro using Javascript

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!

Export HTML Table to MS Excel 2010

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.

Export html tables to Excel using (or not) javascript

I made an statistics application which only permits actually to display various informations, using angular. Now i want to improve it.
On a page i have 3 big html tables containing the statistics and i'd like to let the users download them to use them on excel.
I've seen many ways to do it only in javascript but it's a bit too basic and for example, we can ony create one sheet by excel file. I used for a previous project a php Class to create my excel files which was really better.
Can you advise me about a way to create a more complex excel file, on my angular application, by calling maybe an external script or something?
Thank you very much
There are a plenty of solutions for your problem. All depends of your application, backend capabilities, frameworks used and so on...
A solution could be to create a webservice that uses the Apache POI apis.

Include html files in an html file on a local file system?

I have a help system that is completely offline, no server, using file://.
I have one main page, with hundreds of line of html that represent many sections of the help system. I would like to stick each section in a html file and just include it. Unfortunately it seems like this is only possible with some nifty server side include techniques, with HTML5 (which I do not want to assume my users have), or with a nasty javascript hack where you copy your html file into js files with document.write calls for every line as written about here: Ways to include html in html.
What about something like handlebars.js or mustache.js? Can I use templating?
Since you don't want to use server-side includes, I would suggest using a static site generator (SSG).
If you are not familiar with SSG's, they allow you generate HTML pages from templates & includes (often Handlebars templates) and HTML, Markdown, JSON, or YAML, content using a CLI.
If you want to get started with an SSG, there are plenty of options, from Ruby based Jekyll, or Node.js based Assemble. In my opinion, Assemble is the best option and I would highly recommend it.

Exporting data to excel using javascript under following constraint

I have a project on exporting data to excel using JavaScript. But the constraints are : It should work for all browsers unlike ActiveXObject(that works only for Internet Explorer), window.open(that doesn't works for internet explorer).
It should not depend on other applications like Flash (I have seen a code using jQuery and Flash, but I can't use that in my project) e.t.c.
Please tell me whether it is possible and if it is, then suggest me a method to do this...
And one more thing, Manual work shouldn't be there or if it is, then it should be very less. In other words, it should be completely automated.
Suggestions:
use CSV file format and write a CSV writer in JavaScript yourself
use Microsoft's Office Open XML file format (xlsx) and write JavaScript code that generates such a file (should not be too difficult as it is XML based and there should be a lot of code around generating XML in JavaScript)

Categories