开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜