Javascript打开内容types
在JavaScript中我有一个string,包含一个SpreadsheetML文件(Excel的XML)
我想打开一个新窗口,并将其写入该数据,但将其打开为excel。
我可以做到这一点从JavaScript?
是的,你可以用数据url来做这件事。 首先,将文档编码为base64 。 然后,使用以下URL作为您的窗口的来源:
var mtype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; var url = 'data:' + mtype + ';base64,' + base64data; window.open(url);
这将需要一个现代的 浏览器 。