What's the correct way to export an HTML table as an Excel file so that the user can click a button and download the Excel file (ideally using Angular and without using server)?
I've seen many answers like this:
Export to xls using angularjs but doing this gives an error similar to the following:
"The file format and extension dont match... The file could be corrupted..."
and I believe the file is actually in HTML or XML format, not actual Excel.
The warning does not present a good image to the user.
What's the right way to actually export a file as Excel without using the server?
Or is the server required to create the file?
If you are just using tabular data, then I would argue that the best solution would be building a CSV file. This could be natively opened by excel and converted into an XLS file if necessary. You can do so by arranging your data with a data URI. The octet-stream will force a file download rather than opening in browser. Here is an example:
CSV
Related
I'm new to Excel Web Add-Ins and want to figure out if it's possible to make an add-in that can export a custom file.
I've looked around and all I find are Excel specific commands like Workbook.SaveAs() but I can't find anything on making custom export functions. I need to convert the file into XML but a specific XML setup and so, I could just work the data before I save it to XML. But again, can't find much of anything to suggest that this is supported.
How would I go about writing a file to disk from Excel that isn't just the Workbook?
There's no such API to support exporting custom file to disk. It seems we can have workaround to do this work, this workaround just works for excel online.
Please see this link:
How to create a file in memory for user to download, but not through server?
The closest thing there is for what you want to do is:
Office.context.document.getFileAsync(Office.FileType.Compressed, (result) => {
const file = result.value;
// do whatever ...
});
The file variable in this case contains the entire document in Office Open XML (OOXML) format as a byte array.
I want to parse excel file using javascript in html. I successfully parsed it by reading . But i want it automatically read the excel from current directory on page load. is it possible? Because i want to run the html in as local file without any server.
Yes you can, using SheetJS
you will simply specify in the init according to docs appropriate file you want to open and then it is easy as follow docs
There are too many examples how to create EXCEL file, like this:
create Excel with xPages
But I really need Excel xlsx format not xls. Just defining xlsx file extension and change content type doesn't help:
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
Vlad,
Setting the content type to xls or xlsx has the same effect: it tells the browser to hand over to Excel. It still would send HTML that excel renders.
It is up to the user to save as xlsx.
If you really need a ready made xlsx you need to create an XAgent that renders the binary xlsx format. The easiest way is Apache POI library, which is available for XPages through OpenNTF.
Check the samples there. They should do what you need.
What I'd like to do is run a batch process on a bunch of PDF files in a folder. This process would execute a piece of javascript who's result would then be saved in a file/csv along with all of the other responses. Is doing something like this possible?
I've researched batch processes and I know how to create one but I can't figure out how to save data into a file using Adobe JS, and then save EVERY output from EVERY pdf into the same file.
Yes. It's possible... indirectly. Acrobat won't let you just write a CSV file out to disk. However, it will allow you to create a new PDF file and add the CSV string as a file attachment to it. You can then use JavaScript to export the attachment. Part of your batch script will be to open the PDF that holds the CSV output (the "storage" file), get the current CSV attachment as a string, append your data, save it back as an attachment and close the file. You will need to "disclose" the storage file in order to manipulate it via JavaScript from another file. That's all documented in the JavaScript API.
I am trying to export self updating .xls file from other website to mine as csv, so that I will be able to create "Live data graphs" using Highcharts JS for different parameters from this , which also update automatically according to the file.
OR
I have another method, same self updating data is on a website in form of table which gets updated with time. So , is it possilble to pull data from there for specific parameters and generate live data graphs?
Please Help.....
How about using a Google spreadsheet?
http://dataist.wordpress.com/2012/11/23/using-google-spreadsheet-as-a-database/
If I got you right, you want to convert an .xls file to .csv ?
Then you'll want to look at this article:
http://www.c-sharpcorner.com/uploadfile/yuanwang200409/how-to-convert-xls-file-into-csv-file-in-c-sharp/
As well as consider some answers on SO:
Is there any simple way to convert .xls file to .csv file? (Excel)
C# converting .xls to .csv without Excel
Personally I like the solution to extract .xls into dataset and then generate you .csv from datatble. (see c# datatable to csv)