Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert xml to excel with multiple worksheet

if I export the below xml to excel 2007...i am able to get the excel sheet correctly.

<Workbook>
<Worksheet >
<MyXml>
    <New A="111" B="222" />
</MyXml>
<MyXml>
    <New A="111" B="222" />
</MyXml>
</Worksheet>
</Workbook>

But I need a workbook with more than one worksheet...How do i specify the xml in this case ?

like image 673
anish mohan Avatar asked Dec 13 '09 06:12

anish mohan


1 Answers

Try this:

<?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">
 <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
  <ActiveSheet>2</ActiveSheet>
 </ExcelWorkbook>
 <Styles>
  <Style ss:ID="Default" ss:Name="Normal">
   <Alignment ss:Vertical="Bottom"/>
   <Borders/>
   <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
   <Interior/>
   <NumberFormat/>
   <Protection/>
  </Style>
 </Styles>
 <Worksheet ss:Name="Sheet1">
  <Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="1" x:FullColumns="1"
   x:FullRows="1" ss:DefaultRowHeight="15">
   <Row>
    <Cell><Data ss:Type="Number">11</Data></Cell>
    <Cell><Data ss:Type="Number">22</Data></Cell>
   </Row>
  </Table>
 </Worksheet>
 <Worksheet ss:Name="Sheet2">
  <Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="1" x:FullColumns="1"
   x:FullRows="1" ss:DefaultRowHeight="15">
   <Row>
    <Cell><Data ss:Type="Number">11</Data></Cell>
    <Cell><Data ss:Type="Number">22</Data></Cell>
   </Row>
  </Table>
 </Worksheet>
</Workbook>

For more help you can take a look at this.

Finally, you can manually create an excel workbook and export it to XML so that you can examine the XML's format.

like image 75
Dana Avatar answered Sep 28 '22 11:09

Dana