Skip to main content

Workbook Object工作簿对象

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

wb.Sheets[sheetname] returns an object representing the worksheet.返回表示工作表的对象。

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.存储工作簿级属性

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 DescriptionExcel说明
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定义的名称

Format Support格式支持 (click to show)

Simple Defined Names简单定义的名称: XLSX/M, XLSB, BIFF8 XLS, XLML, ODS, SYLK

Unicode Defined NamesUnicode定义的名称: XLSX/M, XLSB, BIFF8 XLS, XLML, ODS

Defined Name Comment定义的名称注释: XLSX/M, XLSB, BIFF8 XLS

wb.Workbook.Names is an array of defined name objects which have the keys:是定义的名称对象的数组,这些对象具有键:

KeyDescription
SheetName scope. 名称范围。Sheet Index (0 = first sheet) or null (Workbook)工作表索引(0=第一个工作表)或null(工作簿)
NameCase-sensitive name. 区分大小写的名称。Standard rules apply适用标准规则 **
RefA1-style ReferenceA1样式参考 ("Sheet1!$A$1:$D$20")
CommentComment (only applicable for XLS/XLSX/XLSB)注释(仅适用于XLS/XLSX/XLSB)

Excel allows two sheet-scoped defined names to share the same name. Excel允许两个工作表范围的定义名称共享相同的名称。However, a sheet-scoped name cannot collide with a workbook-scope name. 但是,工作表范围的名称不能与工作簿范围名称冲突。Workbook writers may not enforce this constraint.工作簿编写器不能强制执行此约束。

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 Code NameVBA工作簿代码名
date1904epoch: 0/false for 1900 system, 1/true for 1904历元:1900系统为0/false,1904系统为1/true
filterPrivacyWarn or strip personally identifying info on save保存时警告或删除个人识别信息