最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

xml - Javascript open content type - Stack Overflow

programmeradmin2浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 5

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)

  1. 暂无评论