Javascript open content type
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?
Yes, 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.
精彩评论