2017-03-20 09:02:25 +00:00
|
|
|
#### Data Types
|
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
The raw value is stored in the `v` value property, interpreted based on the `t`
|
|
|
|
type property. This separation allows for representation of numbers as well as
|
|
|
|
numeric text. There are 6 valid cell types:
|
|
|
|
|
|
|
|
| Type | Description |
|
|
|
|
| :--: | :-------------------------------------------------------------------- |
|
|
|
|
| `b` | Boolean: value interpreted as JS `boolean` |
|
|
|
|
| `e` | Error: value is a numeric code and `w` property stores common name ** |
|
|
|
|
| `n` | Number: value is a JS `number` ** |
|
|
|
|
| `d` | Date: value is a JS `Date` object or string to be parsed as Date ** |
|
|
|
|
| `s` | Text: value interpreted as JS `string` and written as text ** |
|
|
|
|
| `z` | Stub: blank stub cell that is ignored by data processing utilities ** |
|
2017-03-20 09:02:25 +00:00
|
|
|
|
2017-04-30 20:37:53 +00:00
|
|
|
<details>
|
2017-09-24 23:40:09 +00:00
|
|
|
<summary><b>Error values and interpretation</b> (click to show)</summary>
|
2017-04-30 20:37:53 +00:00
|
|
|
|
2017-03-20 09:02:25 +00:00
|
|
|
| Value | Error Meaning |
|
|
|
|
| -----: | :-------------- |
|
|
|
|
| `0x00` | `#NULL!` |
|
|
|
|
| `0x07` | `#DIV/0!` |
|
|
|
|
| `0x0F` | `#VALUE!` |
|
|
|
|
| `0x17` | `#REF!` |
|
|
|
|
| `0x1D` | `#NAME?` |
|
|
|
|
| `0x24` | `#NUM!` |
|
|
|
|
| `0x2A` | `#N/A` |
|
|
|
|
| `0x2B` | `#GETTING_DATA` |
|
|
|
|
|
2017-04-30 20:37:53 +00:00
|
|
|
</details>
|
|
|
|
|
2017-03-20 09:02:25 +00:00
|
|
|
Type `n` is the Number type. This includes all forms of data that Excel stores
|
|
|
|
as numbers, such as dates/times and Boolean fields. Excel exclusively uses data
|
|
|
|
that can be fit in an IEEE754 floating point number, just like JS Number, so the
|
|
|
|
`v` field holds the raw number. The `w` field holds formatted text. Dates are
|
|
|
|
stored as numbers by default and converted with `XLSX.SSF.parse_date_code`.
|
|
|
|
|
|
|
|
Type `d` is the Date type, generated only when the option `cellDates` is passed.
|
|
|
|
Since JSON does not have a natural Date type, parsers are generally expected to
|
|
|
|
store ISO 8601 Date strings like you would get from `date.toISOString()`. On
|
|
|
|
the other hand, writers and exporters should be able to handle date strings and
|
|
|
|
JS Date objects. Note that Excel disregards timezone modifiers and treats all
|
2018-02-14 20:06:35 +00:00
|
|
|
dates in the local timezone. The library does not correct for this error.
|
|
|
|
|
|
|
|
Type `s` is the String type. Values are explicitly stored as text. Excel will
|
|
|
|
interpret these cells as "number stored as text". Generated Excel files
|
|
|
|
automatically suppress that class of error, but other formats may elicit errors.
|
2017-03-20 09:02:25 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
Type `z` represents blank stub cells. 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`.
|
2017-03-20 09:02:25 +00:00
|
|
|
|
|
|
|
|
2017-03-21 20:44:35 +00:00
|
|
|
#### Dates
|
|
|
|
|
2017-06-01 21:22:11 +00:00
|
|
|
<details>
|
2017-09-24 23:40:09 +00:00
|
|
|
<summary><b>Excel Date Code details</b> (click to show)</summary>
|
2017-06-01 21:22:11 +00:00
|
|
|
|
2017-03-21 20:44:35 +00:00
|
|
|
By default, Excel stores dates as numbers with a format code that specifies date
|
|
|
|
processing. For example, the date `19-Feb-17` is stored as the number `42785`
|
|
|
|
with a number format of `d-mmm-yy`. The `SSF` module understands number formats
|
|
|
|
and performs the appropriate conversion.
|
|
|
|
|
|
|
|
XLSX also supports a special date type `d` where the data is an ISO 8601 date
|
|
|
|
string. The formatter converts the date back to a number.
|
|
|
|
|
|
|
|
The default behavior for all parsers is to generate number cells. Setting
|
|
|
|
`cellDates` to true will force the generators to store dates.
|
|
|
|
|
2017-06-01 21:22:11 +00:00
|
|
|
</details>
|
|
|
|
|
|
|
|
<details>
|
2017-09-24 23:40:09 +00:00
|
|
|
<summary><b>Time Zones and Dates</b> (click to show)</summary>
|
2017-06-01 21:22:11 +00:00
|
|
|
|
|
|
|
Excel has no native concept of universal time. All times are specified in the
|
|
|
|
local time zone. Excel limitations prevent specifying true absolute dates.
|
|
|
|
|
|
|
|
Following Excel, this library treats all dates as relative to local time zone.
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
<details>
|
2017-09-24 23:40:09 +00:00
|
|
|
<summary><b>Epochs: 1900 and 1904</b> (click to show)</summary>
|
2017-06-01 21:22:11 +00:00
|
|
|
|
|
|
|
Excel supports two epochs (January 1 1900 and January 1 1904), see
|
|
|
|
["1900 vs. 1904 Date System" article](http://support2.microsoft.com/kb/180162).
|
|
|
|
The workbook's epoch can be determined by examining the workbook's
|
|
|
|
`wb.Workbook.WBProps.date1904` property:
|
|
|
|
|
|
|
|
```js
|
|
|
|
!!(((wb.Workbook||{}).WBProps||{}).date1904)
|
|
|
|
```
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|