Excel 2007 Open XML文件结构(1)
下面通过对如图20-1所示的工作簿文件进行剖析,以使读者深入地了解Excel 2007 Open XML文件的结构。
![]() |
图20-1 Excel 2007工作簿 |
Excel 2007 Open XML文件其实是一个zip文件。为了分析其结构,需要将其解压出来。因此,计算机系统中需要安装管理zip文件的软件(例如WinZip、WinRar等)。下面列出具体的步骤:
(1)将工作簿文件名"测试Excel2007文件结构.xlsx"的后面添加一个".zip"扩展名,修改为"测试Excel2007文件结构.xlsx.zip"。
(2)接着当弹出如图20-2所示的警告信息,单击【是】按钮,完成文件名的修改。
(3)将上步更名的文件解压,得到如图20-3所示的文件目录结构。
![]() |
图20-2 警告信息 |
![]() |
(点击查看大图)图20-3 解压后的文件结构 |
(4)在解压后的文件夹中,最重要的文件是文件夹xl中的workbook.xml文件,该文件的代码如下:<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/
main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships">
<fileVersion appName="xl" lastEdited="4" lowestEdited="4" rupBuild=
"4505" />
<workbookPr defaultThemeVersion="124226" />
- <bookViews>
<workbookView xWindow="480" yWindow="15" windowWidth="8670" window
Height="5070" />
</bookViews>
- <sheets>
<sheet name="工作表1" sheetId="1" r:id="rId1" />
<sheet name="工作表2" sheetId="2" r:id="rId2" />
<sheet name="Sheet3" sheetId="3" r:id="rId3" />
</sheets>
<calcPr calcId="125725" />
</workbook>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> |
workbook.xml文件包含一对<sheets>标签,其中的每个<sheet>元素都代表Excel 2007文件中的一个,工作表的名称就是其name属性的值,在上面的代码中,分别有3个工作表,即工作表1、工作表2和工作表3。<sheet>元素中r:id属性的值指出保存工作表数据的XML文件。
(5)打开"xl/_rels/workbook.xml.rels"文件,其内容如下所示:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/ relationships">
<Relationship Id="rId3"
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationsh- ips/worksheet"
Target="worksheets/sheet3.xml" />
<Relationship Id="rId2"
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationsh- ips/worksheet"
Target="worksheets/sheet2.xml" />
<Relationship Id="rId1"
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationsh- ips/worksheet"
Target="worksheets/sheet1.xml" />
<Relationship Id="rId6"
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationsh- ips/sharedStrings"
Target="sharedStrings.xml" />
<Relationship Id="rId5"
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationsh- ips/styles"
Target="styles.xml" />
<Relationship Id="rId4"
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationsh- ips/theme"
Target="theme/theme1.xml" />
</Relationships>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> |