cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Convert XML data into XLS

Former Member
0 Likes
3,333

Hi,

Any body knows how to convert XML data into XLS. please let me know.

Regards,

Preetham

View Entire Topic
Former Member
0 Likes

Delimited files are definitely easiest if that works for you. Another option would be to convert your XML to Excel Spreadsheet XML. The schema for urn:schemas-microsoft-com:office:spreadsheet is huge, but you can download it from MS. I used XSLT to keep from having to deal with the schema. However, you could also create a slimmed down version of the xml schema supporting only what you need. It just depends on what you need to do. The following example will open directly into Excel (the file extension should still be .xml)


<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" 	
 	xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
 <Worksheet ss:Name="Sheet1">
  <Table>
   <Row>
    <Cell><Data ss:Type="String">Sheet1-A1</Data></Cell>
    <Cell><Data ss:Type="String">Sheet1-B1</Data></Cell>    
   </Row>
   <Row>
    <Cell><Data ss:Type="String">Sheet1-A2</Data></Cell>
    <Cell><Data ss:Type="String">Sheet1-B2</Data></Cell>    
   </Row>
  </Table>
 </Worksheet>
 <Worksheet ss:Name="Sheet2">
  <Table>
   <Row>
    <Cell><Data ss:Type="String">Sheet2-A1</Data></Cell>
    <Cell><Data ss:Type="String">Sheet2-B1</Data></Cell>    
   </Row>
   <Row>
    <Cell><Data ss:Type="String">Sheet2-A2</Data></Cell>
    <Cell><Data ss:Type="String">Sheet2-B2</Data></Cell>    
   </Row>
  </Table>
 </Worksheet>
</Workbook>

If you add <?mso-application progid="Excel.Sheet"?> to the XML, windows will know to open it using Excel when you double click it. If you donu2019t use this it still works, but you will need to use u201COpen With -> Excelu201D instead. Just save any current XLS file as u201CSpreadsheet XMLu201D (not Data XML) to see an example of a fully formatted file. It may be large, but the simple example above still works without all the formatting. Of course, some things are not supported in this format (shapes, objects, charts, etc), but thatu2019s expected.