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:
- The document saved as
xls(orxlsx) opens fine onOpeOffice\LibreOfficebut throws an error onExcel, and - I do not seem to find a way to add images to the file.
I do not want to save it as an xml file since opening it defaults to a web browser in most cases.