Cell Object单元格对象
Cell objects are plain JS objects with keys and values following the convention:单元格对象是普通JS对象,其键和值符合约定:
v | |
t | b Boolean, e Error, n Number, d Date, s Text, z Stubb 布尔值、e 错误、n 数字、d 日期、s 文本、z 存根 |
z | |
w | |
f | |
F | |
D | true ,则数组公式是动态的(如果适用) |
l | |
c | |
r | |
h | |
s |
Built-in export utilities (such as the CSV exporter) will use the 内置导出实用程序(如CSV导出器)将使用w
text if it is available. w
文本(如果可用)。To change a value, be sure to delete 要更改值,请确保在尝试导出之前删除cell.w
(or set it to undefined
) before attempting to export. cell.w
(或将其设置为undefined
)。The utilities will regenerate the 如果可能,实用程序将从数字格式(w
text from the number format (cell.z
) and the raw value if possible.cell.z
)和原始值重新生成w
文本。
The actual array formula is stored in the 实际数组公式存储在数组范围中第一个单元格的f
field of the first cell in the array range. f
字段中。Other cells in the range will omit the 范围中的其他单元格将忽略f
field.f
字段。
Data Types数据类型
The raw value is stored in the 原始值存储在v
value property, interpreted based on the t
type property. v
值属性中,根据t
类型属性进行解释。This separation allows for representation of numbers as well as numeric text. 这种分离允许数字和数字文本的表示。There are 6 valid cell types:有6种有效的单元格类型:
b | Booleanboolean boolean |
e | Errorw property stores common name w 属性存储公共名称** |
n | Numbernumber ** |
d | DateDate object or string to be parsed as DateDate 对象或被解析为日期的字符串 ** |
s | Textstring and written as textstring 并写为文本 ** |
z | Stub |
Error values and interpretation误差值和解释 (click to show)
Value | |
---|---|
0x00 | #NULL! |
0x07 | #DIV/0! |
0x0F | #VALUE! |
0x17 | #REF! |
0x1D | #NAME? |
0x24 | #NUM! |
0x2A | #N/A |
0x2B | #GETTING_DATA |
Type 类型n
is the Number type. n
是数字类型。This includes all forms of data that Excel stores as numbers, such as dates/times and Boolean fields. 这包括Excel存储为数字的所有形式的数据,例如日期/时间和布尔字段。Excel exclusively uses data that can be fit in an IEEE754 floating point number, just like JS Number, so the Excel专门使用可以放入IEEE754浮点数中的数据,就像JS数字一样,因此v
field holds the raw number. v
字段保存原始数字。The w
field holds formatted text. w
字段保存格式化文本。Dates are stored as numbers by default and converted with 默认情况下,日期存储为数字,并使用XXLSX.SSF.parse_date_code
.XLSX.SSF.parse_date_code
进行转换。
Type 类型d
is the Date type, generated only when the option cellDates
is passed. d
是日期类型,仅当传递选项cellDates
时生成。Since JSON does not have a natural Date type, parsers are generally expected to store ISO 8601 Date strings like you would get from 由于JSON没有自然的日期类型,解析器通常需要存储ISO 8601日期字符串,就像从date.toISOString()
. date.toISOString()
获得的一样。On the other hand, writers and exporters should be able to handle date strings and JS Date objects. 另一方面,编写器和导出器应该能够处理日期字符串和JS日期对象。Note that Excel disregards timezone modifiers and treats all dates in the local timezone. 请注意,Excel忽略时区修饰符,并处理本地时区中的所有日期。The library does not correct for this error. 库无法更正此错误。Dates are covered in more detail in the Dates section日期部分详细介绍了日期。
Type 类型s
is the String type. s
是字符串类型。Values are explicitly stored as text. 值显式存储为文本。Excel will interpret these cells as "number stored as text". Excel将这些单元格解释为“以文本形式存储的数字”。Generated Excel files automatically suppress that class of error, but other formats may elicit errors.生成的Excel文件自动抑制该类错误,但其他格式可能会引发错误。
Type z
represents blank stub cells. z
型表示空白存根单元格。They are generated in cases where cells have no assigned value but hold comments or other metadata. 它们是在单元格没有赋值但包含注释或其他元数据的情况下生成的。They are ignored by the core library data processing utility functions. 它们被核心库数据处理实用程序函数忽略。By default these cells are not generated; the parser 默认情况下,不会生成这些单元格;解析器sheetStubs
option must be set to true
.sheetStubs
选项必须设置为true
。