Building XML Files Outside of Microsoft Excel

When you save a Microsoft Excel 2002 workbook in the XML spreadsheet file format, the program uses the XML Spreadsheet Schema (XML-SS) to encode the data and formatting of the spreadsheet. Based on what you've already learned in this chapter about XML spreadsheet elements and attributes, it is quite easy to create an XML spreadsheet file outside of Microsoft Excel. Assume that you are working on a computer where Excel is not installed and need to prepare a spreadsheet containing quarterly sales figures for the East region. For the following exercise, you can use Notepad as your editor.

The following exercise demonstrates how to use Notepad to create an Excel spreadsheet in XML format.

1. Enter the XML code shown in Figure 17-9.

2. Save the file as EastRegion.xml.

3. Assume you've just received an e-mail with the EastRegion.xml file attachment. Open the EastRegion.xml document in Microsoft Excel 2000. The XML output is shown in Figure 17-10.

^ EastRegjon xiTil - Notepad

File Edit Fcxmaf Help

Wo rkb o ok xml n s=" u m :sc h em as- microsoft-co m. office :sp read s heef' xmlns:o=" urn :s c hemas- microsoft-c o m:offic e :offic e" xmlns:x="um: s chemas- m ic roe oft- c om :offic e: exce r xmins :ss="urri: s chemas-m ic rosoft-c om e: s p rea d sheet* xmlns:html=" htlp ;/Mww.w3. o rgrTR/R E C-hlm 14 «Styles*

<Fontss:FontWame=Tahoma" ssiSize^li" ss:Boid=T7>

«Worksheet ss:Name^"Sales Summary"*


<Cell ><Dala ss:Typ e="S?rlng,,>Reg ion </Dala* </Cell > «Cell "Data ss:Type="Slring"M st Gtr</Data WCell* ■<Cell»*Dafa ss:Type="Siring"»2nd Qlr</Data></CeJI* <Cell>*Data ss:Type="Sfring">3rd Qtr*/Data>«/Cell> <Cell><Data ss:Type="String">4th Qtr</Data>«/Cell> «Cell ><Data ss:Typ e="Slring">Total<iD ata></0 el l> */Row> <Row>

<Cell ><Data ss;Typ B="String">Ea st<JData></CeII> <Cell ><Oata ss:Typ e="Nu mtie f > 2030 0 </Data> </Ce II > <ce li >«Data ss:Typ e="Nu mbe r > 3200 o «/Data* </ce II > -=Cell> <Data s s:Typ e="Nu mbe i" > 1500 0 </Data> </Ce1l > <Ce II > <Data ss:Typ e="Nu mbe r" > 24 34 0 «/Data* </Cell > <Cell ss;StylelD="&1" ss;Forrnula="=SUM(R2C2:R2C5)"* <Data ss:Tvpe=yNumtier>24340</Data>

<JTable> <)Worksheet> </Workbook>

0 0

Post a comment