In javascript I have a string, containing an SpreadsheetML file (excel xml)
I want to open a new window, and write this data to it, but have it open as excel.
Can I do that from javascript?
In javascript I have a string, containing an SpreadsheetML file (excel xml)
I want to open a new window, and write this data to it, but have it open as excel.
Can I do that from javascript?
Share Improve this question edited Jul 20, 2011 at 13:26 CaffGeek asked Jul 19, 2011 at 16:13 CaffGeekCaffGeek 22.1k18 gold badges105 silver badges186 bronze badges 3- a true XLXS file is a zip archive containing several XML zipped files. Do you actually have a string contaning the binary of an XLSX files, or just a XML content of an Excel-XML worksheet data? – Skrol29 Commented Jul 19, 2011 at 17:50
- Yes, I was mistaken, it was actually SpreadsheetML, not xlsx. – CaffGeek Commented Jul 19, 2011 at 19:30
- you should aslo drop the xlsx tag... – Skrol29 Commented Jul 19, 2011 at 22:03
1 Answer
Reset to default 5Yes, you can do that with a data URL,. First, encode the document as base64. Then, use the following URL as source of your window:
var mtype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
var url = 'data:' + mtype + ';base64,' + base64data;
window.open(url);
This will require a modern browser.