PHP Using DOM to output XLS

xanatos1992

New Member
I'm trying to output an XLS file in the XML format.This is what the data should look like for Excel 2003 to render (can be saved as an xls file):\[code\]<? 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'> <Worksheet ss:Name='Connections'> <Table> <Row> <Cell><ss:Data ss:Type='String' xmlns="http://www.w3.org/TR/REC-html40"><B>Test</B></Data></Cell> <Cell><ss:Data ss:Type='String' xmlns="http://www.w3.org/TR/REC-html40"><B>Test 2</B></Data></Cell> </Row> <Row> <Cell><ss:Data ss:Type='String'>Data</Data></Cell> <Cell><ss:Data ss:Type='String'>More data</Data></Cell> </Row> </Table> </Worksheet></Workbook>\[/code\]What I'm currently getting is this:\[code\]<?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:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:html="http://www.w3.org/TR/REC-html40"> <Worksheet ss:Name="Test"> <Table> <Row> <Cell><ss:Data xmlns="http://www.w3.org/TR/REC-html40" ss:Type="string"><B>Test</B></ss:Data></Cell> <Cell><ss:Data xmlns="http://www.w3.org/TR/REC-html40" ss:Type="string"><B>Test 2</B></ss:Data></Cell> </Row> <Row> <Cell><ss:data ss:type="string">Data</ss:Data></Cell> <Cell><ss:data ss:type="string">More data</ss:Data></Cell> </Row> </Table> </Worksheet></Workbook>\[/code\]Which Excel can't parse. It throws four of these errors in its log file:\[code\]XML ERROR in TableREASON: Bad ValueFILE: test.xlsGROUP: CellTAG: DataATTRIB: TypeVALUE: string\[/code\]I think that the main problem is that the \[code\]<ss:Data>\[/code\] tags which I'm creating with \[code\]DomDocument::CreateElement('ss:Data')\[/code\] should be closed with \[code\]</Data>\[/code\], whereas DomDocument is outputting \[code\]</ss:Data>\[/code\]. I can't use \[code\]CreateElementNS()\[/code\], because there isn't a namespace (I think
 
Back
Top