Skip to main content

Workbook Object工作簿对象

For a given workbook object wb:对于给定的工作簿对象wb

wb.SheetNames is an ordered list of the sheets in the workbook.是工作簿中工作表的有序列表。

wb.Sheets is an object whose keys are worksheet names (from SheetNames) and whose values are worksheet objects.是一个对象,其键是工作表名称(来自SheetNames),其值是工作表对象。

wb.Props is an object storing the standard properties. 是存储标准属性的对象。wb.Custprops stores custom properties. 存储自定义属性。Since the XLS standard properties deviate from the XLSX standard, XLS parsing stores core properties in both places.由于XLS标准特性与XLSX标准不同,XLS解析将核心特性存储在两个位置。

wb.Workbook stores workbook-level attributes.存储工作簿级别的属性

When reading a file, wb.bookType is the determined book type.读取文件时,wb.bookType是已确定的工作簿类型。

File Properties文件属性

The various file formats use different internal names for file properties. 各种文件格式对文件属性使用不同的内部名称。The workbook Props object normalizes the names:工作簿Props对象规范化名称:

File Properties文件属性 (click to hide)
JS NameExcel Description
TitleSummary tab "Title"
SubjectSummary tab "Subject"
AuthorSummary tab "Author"
ManagerSummary tab "Manager"
CompanySummary tab "Company"
CategorySummary tab "Category"
KeywordsSummary tab "Keywords"
CommentsSummary tab "Comments"
LastAuthorStatistics tab "Last saved by"
CreatedDateStatistics tab "Created"

For example, to set the workbook title property:例如,要设置工作簿标题属性:

if(!wb.Props) wb.Props = {};
wb.Props.Title = "Insert Title Here";

Custom properties are added in the workbook Custprops object:自定义属性添加到工作簿Custprops对象中:

if(!wb.Custprops) wb.Custprops = {};
wb.Custprops["Custom Property"] = "Custom Value";

Writers will process the Props key of the options object:写入程序将处理选项对象的Props密钥:

/* force the Author to be "SheetJS" */
XLSX.write(wb, { Props: { Author: "SheetJS" } });

Workbook-Level Attributes工作簿级别属性

wb.Workbook stores workbook-level attributes.存储工作簿级别的属性。

Defined Names已定义的名称

wb.Workbook.Names is an array of defined name objects. Defined names are discussed in more detail in "Defined Names"是已定义名称对象的数组。定义的名称在“定义的名称”中有更详细的讨论

Workbook Views工作簿视图

wb.Workbook.Views is an array of workbook view objects which have the keys:是工作簿视图对象的数组,这些对象具有以下键:

KeyDescription
RTLIf true, display right-to-left如果为true,则从右向左显示

Miscellaneous Workbook Properties其他工作簿属性

wb.Workbook.WBProps holds other workbook properties:保存其他工作簿属性:

KeyDescription描述
CodeNameVBA Workbook Name
date1904epoch: 0/false for 1900 system, 1/true for 1904
filterPrivacyWarn or strip personally identifying info on save保存时警告或删除个人识别信息

Sheet Metadata工作表元数据

wb.Workbook.Sheets is an array of sheet metadata objects which have the keys:是图纸元数据对象的数组,这些对象具有以下键:

KeyDescription
HiddenSheet Visibility工作表可见性
CodeNameVBA Sheet Code Name