Sheet Objects工作表对象
Excel supports 4 different types of "sheets":Excel支持4种不同类型的“工作表”:
- "worksheets": normal sheets
- "chartsheets": full-tab charts
- "macrosheets": legacy (pre-VBA) macros
- "dialogsheets": legacy (pre-VBA) dialogs
Generic Sheet Object通用工作表对象
Generic sheets are plain JavaScript objects. 通用表是普通的JavaScript对象。Each key that does not start with 每个不以!
is an A1
-style address whose corresponding value is a cell object.!
开头的键是A1
样式的地址,其对应值为单元格对象。
sheet[address]
returns the cell object for the specified address.返回指定地址的单元格对象。
Sheet Properties工作表属性
Each key starts with 每个键都以!
. !
开头。The properties are accessible as 属性可作为sheet[key]
.sheet[key]
访问。
-
sheet['!ref']
: A-1 based range representing the sheet range.:基于A-1的范围,表示工作表范围。Functions that work with sheets should use this parameter to determine the range.处理工作表的函数应使用此参数来确定范围。Cells that are assigned outside of the range are not processed.不处理分配在范围之外的单元格。In particular, when writing a sheet by hand, cells outside of the range are not included特别是,当用手书写纸张时,不包括范围外的单元格Functions that handle sheets should test for the presence of处理表单的函数应测试是否存在!ref
field.!ref
字段。If the如果!ref
is omitted or is not a valid range, functions are free to treat the sheet as empty or attempt to guess the range.!ref
被省略或不是有效范围,函数可以自由将工作表视为空或尝试猜测范围。The standard utilities that ship with this library treat sheets as empty (for example, the CSV output is empty string).此库附带的标准实用程序将工作表视为空(例如,CSV输出为空字符串)。When reading a worksheet with the当读取设置了sheetRows
property set, the ref parameter will use the restricted range.sheetRows
属性的工作表时,ref参数将使用受限范围。The original range is set at原始范围设置为ws['!fullref']
ws['!fullref']
-
sheet['!margins']
: Object representing the page margins.:表示页边距的对象。The default values follow Excel's "normal" preset.默认值遵循Excel的“常规”预设。Excel also has a "wide" and a "narrow" preset but they are stored as raw measurements.Excel也有“宽”和“窄”预设,但它们存储为原始测量值。The main properties are listed below:主要性能如下:
Page margin details页边距详细信息 (click to show)
"normal" | "wide" | "narrow" | ||
---|---|---|---|---|
left | 0.7 | 1.0 | 0.25 |
|
right | 0.7 | 1.0 | 0.25 |
|
top | 0.75 | 1.0 | 0.75 |
|
bottom | 0.75 | 1.0 | 0.75 |
|
header | 0.3 | 0.5 | 0.3 |
|
footer | 0.3 | 0.5 | 0.3 |
/* Set worksheet sheet to "normal" */
ws["!margins"]={left:0.7, right:0.7, top:0.75,bottom:0.75,header:0.3,footer:0.3}
/* Set worksheet sheet to "wide" */
ws["!margins"]={left:1.0, right:1.0, top:1.0, bottom:1.0, header:0.5,footer:0.5}
/* Set worksheet sheet to "narrow" */
ws["!margins"]={left:0.25,right:0.25,top:0.75,bottom:0.75,header:0.3,footer:0.3}
Worksheet Object工作表对象
In addition to the aforementioned sheet keys, worksheets also add:除了上述工作表索引外,工作表还添加了:
-
ws['!cols']
: array of column properties objects.:列属性对象的数组。Column widths are actually stored in files in a normalized manner, measured in terms of the "Maximum Digit Width" (the largest width of the rendered digits 0-9, in pixels).列宽实际上以规范化的方式存储在文件中,根据“最大数字宽度”(渲染数字的最大宽度0-9,以像素为单位)进行测量。When parsed, the column objects store the pixel width in the解析时,列对象在wpx
field, character width in thewch
field, and the maximum digit width in theMDW
field.wpx
字段中存储像素宽度,在wch
字段中存储字符宽度,在MDW
字段中存储最大数字宽度。 -
ws['!rows']
: array of row properties objects as explained later in the docs.:行属性对象的数组,如文档稍后所述。Each row object encodes properties including row height and visibility.每个行对象编码属性,包括行高和可见性。 -
ws['!merges']
: array of range objects corresponding to the merged cells in the worksheet.:与工作表中的合并单元格相对应的范围对象数组。Plain text formats do not support merge cells.纯文本格式不支持合并单元格。CSV export will write all cells in the merge range if they exist, so be sure that only the first cell (upper-left) in the range is set.CSV导出将写入合并区域中的所有单元格(如果存在),因此请确保仅设置该区域中的第一个单元格(左上角)。 -
ws['!outline']
: configure how outlines should behave.:配置轮廓的行为方式。Options default to the default settings in Excel 2019:选项默认为Excel 2019中的默认设置:
above | false |
|
left | false |
ws['!protect']
: object of write sheet protection properties.:写入工作表保护属性的对象。Thepassword
key specifies the password for formats that support password-protected sheets (XLSX/XLSB/XLS).password
键指定支持密码保护工作表(XLSX/XLSB/XLS)的格式的密码。The writer uses the XOR obfuscation method.作者使用异或模糊处理方法。The following keys control the sheet protection -- set to以下键控制板材保护——设置为false
to enable a feature when sheet is locked or set totrue
to disable a feature:false
以在板材锁定时启用功能,或设置为true
以禁用功能:
Worksheet Protection Details工作表保护详细信息 (click to show)
selectLockedCells | enabled | |
selectUnlockedCells | enabled | |
formatCells | disabled | |
formatColumns | disabled | |
formatRows | disabled | |
insertColumns | disabled | |
insertRows | Insert rows | disabled |
insertHyperlinks | Insert hyperlinks | disabled |
deleteColumns | Delete columns | disabled |
deleteRows | Delete rows | disabled |
sort | Sort | disabled |
autoFilter | Filter | disabled |
pivotTables | Use PivotTable reports | disabled |
objects | Edit objects | enabled |
scenarios | Edit scenarios | enabled |
ws['!autofilter']
: AutoFilter object following the schema::架构后的自动筛选对象:
type AutoFilter = {
ref:string; // A-1 based range representing the AutoFilter table range
}
Other Sheet Types其他工作表类型
Chartsheet Object图表工作表对象
Chartsheets are represented as standard sheets. 图表工作表表示为标准工作表。They are distinguished with the 它们通过!type
property set to "chart"
.!type
属性设置为"chart"
来彰显区分。
The underlying data and 底层数据和!ref
refer to the cached data in the chartsheet. !ref
指图表中的缓存数据。The first row of the chartsheet is the underlying header.图表工作表的第一行是底层标题。
Macrosheet Object宏表对象
Macrosheets are represented as standard sheets. 宏表表示为标准工作表。They are distinguished with the 它们通过!type
property set to "macro"
.!type
属性设置为"macro"
来区分彰显。
Dialogsheet Object对话框工作表对象
Dialogsheets are represented as standard sheets. 对话框工作表表示为标准工作表。They are distinguished with the 它们通过!type
property set to "dialog"
.!type
属性设置为"dialog"
来区分彰显。