首页 > 代码库 > excel格式

excel格式

首先是一段范例 属于最简单的 xml格式的表格 <?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">
<Title>Excel表格</Title>
<LastAuthor>bigtall</LastAuthor>
</DocumentProperties>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Center"/>
<Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/>
</Style>
</Styles>
<Worksheet ss:Name="tt">
<Table>
<Row>
<Cell ss:MergeAcross="6" ><Data ss:Type="String">Hello!World!</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook>

然后通过这些,我们可以知道
<?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">
是必要的
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
</Style>
</Styles>
这些也是必要的
接着有
<Workbook>
<WorkSheet>
<Table>
<Row>
<Cell><Data>[你要输入的文字]</Data></Cell>
</Row>
</Table>
</WorkSheet>
</Workbook>

这样的xml逻辑关系
用这些我们已知的东西 就可以写出如下的文件:

<?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">
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
</Style>
</Styles>
<Worksheet ss:Name = "FS20110408">
<Table>
<Row>
<Cell><Data ss:Type="String">item_id</Data></Cell>
<Cell><Data ss:Type="String">Qty</Data></Cell>
<Cell><Data ss:Type="String">ship_date</Data></Cell>
<Cell><Data ss:Type="String">cancel_date</Data></Cell>
<Cell><Data ss:Type="String">fob_code</Data></Cell>
<Cell><Data ss:Type="String">ship_via</Data></Cell>
<Cell><Data ss:Type="String">factory</Data></Cell>
<Cell><Data ss:Type="String">Notes</Data></Cell>
<Cell><Data ss:Type="String">request_date</Data></Cell>
<Cell><Data ss:Type="String">requestor</Data></Cell>
<Cell><Data ss:Type="String">request_notes</Data></Cell>
<Cell><Data ss:Type="String">targetPrice</Data></Cell>
<Cell><Data ss:Type="String">ponum</Data></Cell>
<Cell><Data ss:Type="String">Client_id</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">NB-ABF2BKCK1</Data></Cell>
<Cell><Data ss:Type="Number">50</Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String">006</Data></Cell>
<Cell><Data ss:Type="String">CK </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String">FS20110408</Data></Cell>
<Cell><Data ss:Type="Number">6</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">NB-ABF2BKCK5</Data></Cell>
<Cell><Data ss:Type="Number">100</Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String">006</Data></Cell>
<Cell><Data ss:Type="String">CK </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String"> </Data></Cell>
<Cell><Data ss:Type="String">FS20110408</Data></Cell>
<Cell><Data ss:Type="Number">6</Data></Cell>
</Row>
</Table>
</Worksheet>
<Worksheet ss:Name = "Sheet1">
<Table>
<Row>
<Cell><Data ss:Type="String">item_id</Data></Cell>
<Cell><Data ss:Type="String">Qty</Data></Cell>
<Cell><Data ss:Type="String">factory</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">NB-ABF2BKCK1</Data></Cell>
<Cell><Data ss:Type="Number">50</Data></Cell>
<Cell><Data ss:Type="String">006</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">NB-ABF2BKCK5</Data></Cell>
<Cell><Data ss:Type="Number">100</Data></Cell>
<Cell><Data ss:Type="String">006</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook>

直接保存成.xls格式的文件吧~用Excel打开马上就能看到拥有多Sheet的表格了~

效果图……其实完全就和excel的xls文件一样