Package Structure包结构
A SpreadsheetML or .xlsx file is a zip file (a package) containing a number of "parts" (typically UTF-8 or UTF-16 encoded) or XML files. SpreadsheetML或.xlsx文件是一个zip文件(一个包),其中包含许多“部分”(通常是UTF-8或UTF-16编码的)或XML文件。The package may also contain other media files such as images. 包还可能包含其他媒体文件,如图像。The structure is organized according to the Open Packaging Conventions as outlined in Part 2 of the OOXML standard ECMA-376.该结构根据OOXML标准ECMA-376第2部分中概述的开放式打包约定进行组织。
You can look at the file structure and the files that comprise a SpreadsheetML file by simply unzipping the .xlsx file. 只需解压缩.xlsx文件,就可以查看文件结构和组成SpreadsheetML文件的文件。
The number and types of parts will vary based on what is in the spreadsheet, but there will always be a [Content_Types].xml, one or more relationship parts, a workbook part , and at least one worksheet. 部件的数量和类型将根据电子表格中的内容而有所不同,但始终会有[Content_types].xml、一个或多个关系部件、一个工作簿部件和至少一个工作表。The core data of the spreadsheet is contained within the worksheet part(s), discussed in more detail at xsxl Content Overview.电子表格的核心数据包含在工作表部分中,在xsxl内容概述中进行了更详细的讨论。
Content Types内容类型
Every package must have a [Content_Types].xml, found at the root of the package. 每个包必须在包的根目录下具有[Content_Types].xml。This file contains a list of all of the content types of the parts in the package. 此文件包含包中零件的所有内容类型的列表。Every part and its type must be listed in [Content_Types].xml. 每个零件及其类型都必须列在[Content_Types].xml中。The following is a content type for the main content part:以下是主要内容部分的内容类型:
<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>
It's important to keep this in mind when adding new parts to the package.在向软件包中添加新部件时,务必记住这一点。
Relationships关系
Every package contains a relationships part that defines the relationships between the other parts and to resources outside of the package. 每个包都包含一个关系部分,该部分定义了其他部分之间以及与包外资源之间的关系。This separates the relationships from content and makes it easy to change relationships without changing the sources that reference targets.这将关系从内容中分离出来,使更改关系变得容易,而无需更改引用目标的源。
For an OOXML package, there is always a relationships part (.rels) within the _rels folder that identifies the starting parts of the package, or the package relationships. 对于OOXML包,在_rels文件夹中始终有一个关系部分(.rels),用于标识包的起始部分或包关系。For example, the following defines the identity of the start part for the content:例如,以下内容定义了内容的开始部分的标识:
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>.
There are also typically relationships within .rels for app.xml and core.xml.app.xml和core.xml的.rels中通常也存在关系。
In addition to the relationships part for the package, each part that is the source of one or more relationships will have its own relationships part. 除了包的关系部分外,作为一个或多个关系源的每个部分都有自己的关系部分。Each such relationship part is found within a _rels sub-folder of the part and is named by appending '.rels' to the name of the part.每个这样的关系部件都位于部件的_rels子文件夹中,并通过在部件名称后面附加“.rels”来命名。
Typically the main content part (workbook.xml) has its own relationships part (workbook.xml.rels). 通常,主内容部分(workbook.xml)有自己的关系部分(workbook.xml.rels)。It will contain relationships to the other parts of the content, such as sheet1.xml, sharedStrings.xml, styles.xml, theme1,xml, as well as the URIs for external links.它将包含与内容其他部分的关系,如sheet1.xml、sharedStrings.xml、styles.xml、theme1、xml以及外部链接的URI。
A relationship can be either explicit or implicit. 关系可以是显式的,也可以是隐式的。For an explicit relationship, a resource is referenced using the Id attribute of a <Relationship> element. 对于显式关系,使用<Relationship>元素的Id属性引用资源。That is, the Id in the source maps directly to an Id of a relationship item, with an explicit reference to the target. 也就是说,源中的Id直接映射到关系项的Id,并显式引用到目标。
For example, a worksheet might contain a hyperlink such as this:例如,工作表可能包含以下超链接:
<w:hyperlink ref="A11" r:id="rId4">
The r:id="rId4" references the following relationship within the relationships part for the worksheet (worksheet1.xml.rels).r:id="rId4"在工作表的关系部分(worksheet1.xml.rels)中引用以下关系。
<Relationship Id="rId4" Type="http://. . ./hyperlink" Target="http://www.google.com/" TargetMode="External"/>
For an implicit relationship, there is no such direct reference to a <Relationship> Id. 对于隐式关系,没有直接引用<Relationship> Id。Instead, the reference is understood.而是,引用是可以理解的。
Parts Specific to SpreadsheetML Documents特定于SpreadsheetML文档的零件
Below is a list of the possible parts of a SpreadsheetML package that are specific to SpreadsheetML spreadsheets. 下面列出了SpreadsheetML数据包中特定于SpreadsheetML电子表格的可能部分。Keep in mind that a spreadsheet may only have a few of these parts. 请记住,电子表格可能只有其中的几个部分。For example, if a spreadsheet has no pivot table, then a pivot table part will not be included in the package.例如,如果电子表格没有透视表,则数据包中将不包括透视表零件。
Part部分 |
Description描述 |
Calculation Chain计算链 |
When the values of cells are calculated from formulas, the order of calculation can be affected by the order in which the values are calculated. 根据公式计算单元格值时,计算顺序可能会受到计算值顺序的影响。This part contains specifies the ordering. A package can contain only one such part.本部分包含指定的顺序。一个包只能包含一个这样的部分。 |
Chartsheet图表 |
Contains a chart that is stored in its owne sheet. 包含存储在其自己的工作表中的图表。A package can contain multiple such parts, referenced from the workbook part.一个包可以包含多个这样的部分,从工作簿部分引用。 |
Comments评论 |
Contains the comments for a given worksheet. 包含给定工作表的注释。Since there may be more than one worksheet, there may be more than one comments part.由于可能有多个工作表,因此可能有多个注释部分。 |
Connections连接 |
A spreadsheet may have connections to external data sources. 电子表格可以连接到外部数据源。This part contains such connections, explaining both how to get such externnal data and how the connection is used within the workbook. 本部分包含此类连接,说明如何获取此类外部数据以及如何在工作簿中使用该连接。There may be only one such part.可能只有一个这样的部分。 |
Custom Property自定义属性 |
Contains user-defined data. 包含用户定义的数据。There may be zero or more such parts.可能没有或有更多这样的部件。 |
Customer XML Mappings客户XML映射 |
Contains a schema for an XML file, and information on the behavior to be used when allowing the schema to be mapped into the spreadsheet. 包含XML文件的架构,以及有关允许将架构映射到电子表格时要使用的行为的信息。There may be only one such part.可能只有一个这样的部分。 |
Dialogsheet对话框样式 |
Contains information about a legacy customer dialog box for a user form. 包含有关用户窗体的旧客户对话框的信息。There may be zero or more such parts.可能没有或有更多这样的部件。 |
Drawings绘图 |
Contains the presentation and layout information for one or more drawing elements that are present in the worksheet. 包含工作表中存在的一个或多个图形元素的表示形式和布局信息。There should be drawings part for each worksheet that has a drawing.每个有图纸的工作表都应该有零件图纸。 |
External Workbook References外部工作簿引用 |
Contains information about data referenced in other spreadsheet packages. 包含有关其他电子表格包中引用的数据的信息。For example, a spreadsheet may have a cell whose value is calculated from data in another spreadsheet. 例如,电子表格可能有一个单元格,其值是根据另一个电子表格中的数据计算的。There may be zero or more such parts.可能没有或有更多这样的部件。 |
Metadata元数据 |
Contains information relating to a cell whose value is related to one or more other cells via Online Analytical Processing (OLAP) technology.包含与单元格相关的信息,该单元格的值通过联机分析处理(OLAP)技术与一个或多个其他单元格相关。 |
Pivot Table数据透视表 |
Contains the definition of a pivot table. 包含透视表的定义。It describes the particulars of the layout of the pivot table, indicating what fields are on the row axis, the column axis, and values areas of the pivot table. 它描述数据透视表布局的细节,指示数据透视表的行轴、列轴和值区域上有哪些字段。And it indicates formatting for the pivot table. 它指示数据透视表的格式。There is a pivot table part for each pivot table within the package. 包中的每个透视表都有一个透视表部件。 |
Pivot Table Cache Definition数据透视表缓存定义 |
The pivot table cache definition defines each field in the pivot cache records part (i.e., the underlying data), including field name and information about the data contained in the field. 数据透视表缓存定义定义数据透视缓存记录部分中的每个字段(即基础数据),包括字段名和字段中包含的数据信息。There is a pivot table cahe definition part for each pivot table within the package.包中的每个透视表都有一个透视表cahe定义部分。 |
Pivot Table Cache Records数据透视表缓存记录 |
Contains the underlying data for a pivot table. 包含透视表的基础数据。There will be zero or one such part for each pivot table in the package.对于包中的每个透视表,将有零个或一个这样的部分。 |
Query Table查询表 |
Contains information that describes how the source table is connected to an external data source and defines the properties that are used when the table is refreshed from the source. 包含描述源表如何连接到外部数据源的信息,并定义从源刷新表时使用的属性。There may be one such part for each table.每个表可能有一个这样的部分。 |
Shared String Table共享字符串表 |
Contains one occurrence of each unique string that occurs in any worksheet within the workbook. 包含工作簿中任何工作表中出现的每个唯一字符串的一个匹配项。There is one such part for a package.对于一个包,有一个这样的部件。 |
Shared Workbook Revision Log共享工作簿修订日志 |
Contains information about edits performed on individual cells in the workbook's worksheets. 包含有关对工作簿工作表中的单个单元格执行编辑的信息。There should be one such part for each editing session每个编辑会话都应该有一个这样的部分 |
Shared Workbook User Data共享工作簿用户数据 |
Contains a list of all users that are sharing the workbook. 包含共享工作簿的所有用户的列表。A package contained zero or one such part.包含零个或一个此类部件的包装。 |
Single Cell Table Definition单单元格表定义 |
Contains information on how to map non-repeating elements from a custom XML file into cells in a worksheet. 包含有关如何将自定义XML文件中的非重复元素映射到工作表中的单元格的信息。There may be one such part per worksheet.每个工作表可能有一个这样的部分。 |
Styles样式 |
Contains all the characteristics for all cells in the workbook, including numeric and text formatting, alignment, font, color, and border. 包含工作簿中所有单元格的所有特征,包括数字和文本格式、对齐方式、字体、颜色和边框。A package contains no more than one such part.一个包只包含一个这样的部分。 |
Table Definition表定义 |
A spreadsheet can contain regions that have clearly labeled columns, rows, and data regions. 电子表格可以包含具有清晰标记的列、行和数据区域的区域。Such regions are called tables, and each worksheet can have zero or more tables. 这些区域称为表,每个工作表可以有零个或多个表。For each table in a worksheet there must be a table definitions part containing a description of the table. 对于工作表中的每个表,必须有一个包含表说明的表定义部分。(The data for the table is stored in the corresponding worksheet part.)(表的数据存储在相应的工作表部分。) |
Volatile Dependencies易失性依赖 |
Cells can contain real-time data formulas that return values that change over time and that require connectivity to programs outside of the workbook. 单元格可以包含实时数据公式,这些公式返回的值随时间变化,并且需要连接到工作簿之外的程序。In cases where those programs are not available, the formulas can use information stored in the volatile dependencies part. 在这些程序不可用的情况下,公式可以使用易失性依赖部分中存储的信息。A package can have only one such part.一个包只能有一个这样的部分。 |
Workbook工作薄 |
Contains data and references to all of the worksheets. 包含所有工作表的数据和引用。There must be one and only one workbook part.必须且只能有一个工作簿部分。 |
Worksheet工作表 |
Contains all the data, formulas, and characteristics of a given worksheet. 包含给定工作表的所有数据、公式和特征。There is one such part for each worksheet in the package. 包中的每个工作表都有一个这样的部分。 |
Parts Shared by Other OOXML Documents由其他OOXML文档共享的部分
There are a number of part types that may appear in any OOXML package. 任何OOXML包中都可能出现许多零件类型。Below are some of the more relevant parts for SpreadsheetML documents.下面是SpreadsheetML文档的一些更相关的部分。
Part部分 |
Description描述 |
Embedded package嵌入式软件包 |
Contains a complete package, either internal or external to the referencing package. 包含引用包的内部或外部的完整包。For example, a SpreadsheetML document might contain a Wordprocessing or PresentationML document.例如,SpreadsheetML文档可能包含文字处理或PresentationML文档。 |
Extended File Properties (often found at docProps/app.xml)扩展文件属性(通常在docProps/app.xml中找到) |
Contains properties specific to an OOXML document--properties such as the template used, the number of pages and words, and the application name and version.包含特定于OOXML文档的属性——例如使用的模板、页数和字数以及应用程序名称和版本。 |
File Properties, Core文件属性,核心 |
Core file properties enable the user to discover and set common properties within a package--properties such as creator name, creation date, title. 核心文件属性使用户能够发现和设置包中的公共属性,如创建者名称、创建日期、标题等属性。Dublin Core properties (a set of metadate terms used to describe resources) are used whenever possible.尽可能使用都柏林核心属性(一组用于描述资源的元日期术语)。 |
Image图像 |
Spreadsheets often contain images. 电子表格通常包含图像。An image can be stored in a package as a zip item. 图像可以作为zip项存储在包中。The item must be identified by an image part relationship and the appropriate content type.项目必须通过图像-零件关系和适当的内容类型进行标识。 |
Theme主题 |
DrawingML is a shared language across the OOXML document types. DrawingML是跨OOXML文档类型的共享语言。It includes a theme part that is included in SpreadsheetML documents when the spreadsheet uses a theme. 它包括一个主题部分,当电子表格使用主题时,该主题部分包含在SpreadsheetML文档中。The theme part contains information about a document's theme, that is, such information as the color scheme, font and format schemes.主题部分包含有关文档主题的信息,即颜色方案、字体和格式方案等信息。 |