Reputation: 8037
I want to export an HTML
table to excel sheet.
I would have done this with CVS format if I didn't have to keep some formatting and add pictures.
I have tries using the Office 2003 XML
format for that, i.e.
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
...
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
...
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
...
</ExcelWorkbook>
<Styles>...</Styles>
<Worksheet ss:Name="Sheet1">...</Worksheet>
</Workbook>
And then some JavaScript
code to "download" it using data URI
and
'data:application/vnd.ms-excel;charset=utf-8, '+
encodeURIComponent(STRING_XML_REPRESENTATION));
I have 2 problems:
xls
(or xlsx
) opens fine on OpeOffice
\ LibreOffice
but throws an error on Excel
, and I do not want to save it as an xml
file since opening it defaults to a web browser in most cases.
Upvotes: 0
Views: 1430
Reputation: 22905
Review ECMA-376. Excel expects all of the files to be included in a zip container (and you must have a few additional files, including [Content_Types].xml
)
Images must be added to the zip container and referenced (review the spec).
Upvotes: 1