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?
For detecting MIME-types, use the aptly named "mimetype" command. It has a number of options for formatting the output, it even has an option for backward compatibility to "file". But most of all, it accepts input not only as file, but also via stdin/pipe, so you can avoid temporary files when processing streams.
content_type is an alias for mimetype. Historically, this parameter was only called mimetype, but since this is actually the value included in the HTTP Content-Type header, it can also include the character set encoding, which makes it more than just a MIME type specification.
A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With