Skip to content

Commit 19620da

Browse files
committed
version bump 0.12.1: BIFF5 features
- BIFF5 write number formats and other features - XLSX/XLSB/BIFF8 Suppress "Number stored as Text" errors - codename awareness (fixes #992 h/t @samusstrike) - updated CFB to 1.0.3 - demo refresh
1 parent f002afa commit 19620da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2606
-1833
lines changed

.spelling

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ APIs
6262
ArrayBuffer
6363
Base64
6464
Booleans
65+
FileReader
6566
JS
6667
NoSQL
6768
README

README.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ function handleFile(e) {
430430
input_dom_element.addEventListener('change', handleFile, false);
431431
```
432432

433+
The [`oldie` demo](demos/oldie/) shows an IE-compatible fallback scenario.
434+
433435
</details>
434436

435437
More specialized cases, including mobile app file processing, are covered in the
@@ -849,11 +851,13 @@ for(var R = range.s.r; R <= range.e.r; ++R) {
849851

850852
### Cell Object
851853

854+
Cell objects are plain JS objects with keys and values following the convention:
855+
852856
| Key | Description |
853857
| --- | ---------------------------------------------------------------------- |
854858
| `v` | raw value (see Data Types section for more info) |
855859
| `w` | formatted text (if applicable) |
856-
| `t` | cell type: `b` Boolean, `n` Number, `e` error, `s` String, `d` Date |
860+
| `t` | type: `b` Boolean, `e` Error, `n` Number, `d` Date, `s` Text, `z` Stub |
857861
| `f` | cell formula encoded as an A1-style string (if applicable) |
858862
| `F` | range of enclosing array if formula is array formula (if applicable) |
859863
| `r` | rich text encoding (if applicable) |
@@ -873,11 +877,18 @@ array range. Other cells in the range will omit the `f` field.
873877

874878
#### Data Types
875879

876-
The raw value is stored in the `v` field, interpreted based on the `t` field.
880+
The raw value is stored in the `v` value property, interpreted based on the `t`
881+
type property. This separation allows for representation of numbers as well as
882+
numeric text. There are 6 valid cell types:
877883

878-
Type `b` is the Boolean type. `v` is interpreted according to JS truth tables.
879-
880-
Type `e` is the Error type. `v` holds the number and `w` holds the common name:
884+
| Type | Description |
885+
| :--: | :-------------------------------------------------------------------- |
886+
| `b` | Boolean: value interpreted as JS `boolean` |
887+
| `e` | Error: value is a numeric code and `w` property stores common name ** |
888+
| `n` | Number: value is a JS `number` ** |
889+
| `d` | Date: value is a JS `Date` object or string to be parsed as Date ** |
890+
| `s` | Text: value interpreted as JS `string` and written as text ** |
891+
| `z` | Stub: blank stub cell that is ignored by data processing utilities ** |
881892

882893
<details>
883894
<summary><b>Error values and interpretation</b> (click to show)</summary>
@@ -906,14 +917,17 @@ Since JSON does not have a natural Date type, parsers are generally expected to
906917
store ISO 8601 Date strings like you would get from `date.toISOString()`. On
907918
the other hand, writers and exporters should be able to handle date strings and
908919
JS Date objects. Note that Excel disregards timezone modifiers and treats all
909-
dates in the local timezone. js-xlsx does not correct for this error.
920+
dates in the local timezone. The library does not correct for this error.
921+
922+
Type `s` is the String type. Values are explicitly stored as text. Excel will
923+
interpret these cells as "number stored as text". Generated Excel files
924+
automatically suppress that class of error, but other formats may elicit errors.
910925

911-
Type `s` is the String type. `v` should be explicitly stored as a string to
912-
avoid possible confusion.
926+
Type `z` represents blank stub cells. They are generated in cases where cells
927+
have no assigned value but hold comments or other metadata. They are ignored by
928+
the core library data processing utility functions. By default these cells are
929+
not generated; the parser `sheetStubs` option must be set to `true`.
913930

914-
Type `z` represents blank stub cells. These do not have any data or type, and
915-
are not processed by any of the core library functions. By default these cells
916-
will not be generated; the parser `sheetStubs` option must be set to `true`.
917931

918932
#### Dates
919933

bits/01_version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
XLSX.version = '0.12.0';
1+
XLSX.version = '0.12.1';

bits/11_ssfutils.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,46 @@ var XLMLFormatMap/*{[string]:string}*/ = ({
1818
"On/Off": '"Yes";"Yes";"No";@'
1919
}/*:any*/);
2020

21+
var SSFImplicit/*{[number]:string}*/ = ({
22+
"5": '"$"#,##0_);\\("$"#,##0\\)',
23+
"6": '"$"#,##0_);[Red]\\("$"#,##0\\)',
24+
"7": '"$"#,##0.00_);\\("$"#,##0.00\\)',
25+
"8": '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',
26+
"23": 'General', "24": 'General', "25": 'General', "26": 'General',
27+
"27": 'm/d/yy', "28": 'm/d/yy', "29": 'm/d/yy', "30": 'm/d/yy', "31": 'm/d/yy',
28+
"32": 'h:mm:ss', "33": 'h:mm:ss', "34": 'h:mm:ss', "35": 'h:mm:ss',
29+
"36": 'm/d/yy',
30+
"41": '_(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)',
31+
"42": '_("$"* #,##0_);_("$"* \(#,##0\);_("$"* "-"_);_(@_)',
32+
"43": '_(* #,##0.00_);_(* \(#,##0.00\);_(* "-"??_);_(@_)',
33+
"44": '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)',
34+
"50": 'm/d/yy', "51": 'm/d/yy', "52": 'm/d/yy', "53": 'm/d/yy', "54": 'm/d/yy',
35+
"55": 'm/d/yy', "56": 'm/d/yy', "57": 'm/d/yy', "58": 'm/d/yy',
36+
"59": '0',
37+
"60": '0.00',
38+
"61": '#,##0',
39+
"62": '#,##0.00',
40+
"63": '"$"#,##0_);\\("$"#,##0\\)',
41+
"64": '"$"#,##0_);[Red]\\("$"#,##0\\)',
42+
"65": '"$"#,##0.00_);\\("$"#,##0.00\\)',
43+
"66": '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',
44+
"67": '0%',
45+
"68": '0.00%',
46+
"69": '# ?/?',
47+
"70": '# ??/??',
48+
"71": 'm/d/yy',
49+
"72": 'm/d/yy',
50+
"73": 'd-mmm-yy',
51+
"74": 'd-mmm',
52+
"75": 'mmm-yy',
53+
"76": 'h:mm',
54+
"77": 'h:mm:ss',
55+
"78": 'm/d/yy h:mm',
56+
"79": 'mm:ss',
57+
"80": '[h]:mm:ss',
58+
"81": 'mmss.0'
59+
}/*:any*/);
60+
2161
/* dateNF parse TODO: move to SSF */
2262
var dateNFregex = /[dD]+|[mM]+|[yYeE]+|[Hh]+|[Ss]+/g;
2363
function dateNF_regex(dateNF/*:string|number*/)/*:RegExp*/ {

bits/18_cfb.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type CFBFiles = {[n:string]:CFBEntry};
3838
/* [MS-CFB] v20130118 */
3939
var CFB = (function _CFB(){
4040
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
41-
exports.version = '1.0.2';
41+
exports.version = '1.0.3';
4242
/* [MS-CFB] 2.6.4 */
4343
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
4444
var L = l.split("/"), R = r.split("/");
@@ -353,14 +353,14 @@ function read_directory(dir_start/*:number*/, sector_list/*:SectorList*/, sector
353353
if(sector_list[o.start] === undefined) sector_list[o.start] = get_sector_list(sectors, o.start, sector_list.fat_addrs, sector_list.ssz);
354354
sector_list[o.start].name = o.name;
355355
o.content = (sector_list[o.start].data.slice(0,o.size)/*:any*/);
356-
prep_blob(o.content, 0);
357356
} else {
358357
o.storage = 'minifat';
359-
if(minifat_store !== ENDOFCHAIN && o.start !== ENDOFCHAIN && sector_list[minifat_store]) {
358+
if(o.size < 0) o.size = 0;
359+
else if(minifat_store !== ENDOFCHAIN && o.start !== ENDOFCHAIN && sector_list[minifat_store]) {
360360
o.content = get_mfat_entry(o, sector_list[minifat_store].data, (sector_list[mini]||{}).data);
361-
prep_blob(o.content, 0);
362361
}
363362
}
363+
if(o.content) prep_blob(o.content, 0);
364364
files[name] = o;
365365
FileIndex.push(o);
366366
}

bits/20_jsutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function keys(o/*:any*/)/*:Array<any>*/ { return Object.keys(o); }
22

33
function evert_key(obj/*:any*/, key/*:string*/)/*:EvertType*/ {
44
var o = ([]/*:any*/), K = keys(obj);
5-
for(var i = 0; i !== K.length; ++i) o[obj[K[i]][key]] = K[i];
5+
for(var i = 0; i !== K.length; ++i) if(o[obj[K[i]][key]] == null) o[obj[K[i]][key]] = K[i];
66
return o;
77
}
88

bits/23_binutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function WriteShift(t/*:number*/, val/*:string|number*/, f/*:?string*/)/*:any*/
188188
} return this;
189189
} else if(f === 'utf16le') {
190190
/*:: if(typeof val !== "string") throw new Error("unreachable"); */
191-
var end/*:number*/ = this.l + t;
191+
var end/*:number*/ = Math.min(this.l + t, this.length);
192192
for(i = 0; i < Math.min(val.length, t); ++i) {
193193
var cc = val.charCodeAt(i);
194194
this[this.l++] = (cc & 0xff);

bits/28_binstructs.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function write_StrRun(run, o) {
2727
return o;
2828
}
2929

30-
/* [MS-XLSB] 2.1.7.121 */
30+
/* [MS-XLSB] 2.5.121 */
3131
function parse_RichStr(data, length/*:number*/)/*:XLString*/ {
3232
var start = data.l;
3333
var flags = data.read_shift(1);
@@ -54,7 +54,7 @@ function write_RichStr(str/*:XLString*/, o/*:?Block*/)/*:Block*/ {
5454
write_XLWideString(str.t, o);
5555
return _null ? o.slice(0, o.l) : o;
5656
}
57-
/* [MS-XLSB] 2.4.325 BrtCommentText (RichStr w/1 run) */
57+
/* [MS-XLSB] 2.4.328 BrtCommentText (RichStr w/1 run) */
5858
var parse_BrtCommentText = parse_RichStr;
5959
function write_BrtCommentText(str/*:XLString*/, o/*:?Block*/)/*:Block*/ {
6060
/* TODO: formatted string */
@@ -108,8 +108,7 @@ var parse_RelID = parse_XLNullableWideString;
108108
var write_RelID = write_XLNullableWideString;
109109

110110

111-
/* [MS-XLSB] 2.5.122 */
112-
/* [MS-XLS] 2.5.217 */
111+
/* [MS-XLS] 2.5.217 ; [MS-XLSB] 2.5.122 */
113112
function parse_RkNumber(data)/*:number*/ {
114113
var b = data.slice(data.l, data.l+4);
115114
var fX100 = (b[0] & 1), fInt = (b[0] & 2);
@@ -137,7 +136,6 @@ function parse_RfX(data /*::, length*/)/*:Range*/ {
137136
cell.e.c = data.read_shift(4);
138137
return cell;
139138
}
140-
141139
function write_RfX(r/*:Range*/, o) {
142140
if(!o) o = new_buf(16);
143141
o.write_shift(4, r.s.r);
@@ -151,13 +149,12 @@ function write_RfX(r/*:Range*/, o) {
151149
var parse_UncheckedRfX = parse_RfX;
152150
var write_UncheckedRfX = write_RfX;
153151

154-
/* [MS-XLSB] 2.5.171 */
155-
/* [MS-XLS] 2.5.342 */
152+
/* [MS-XLS] 2.5.342 ; [MS-XLSB] 2.5.171 */
156153
/* TODO: error checking, NaN and Infinity values are not valid Xnum */
157154
function parse_Xnum(data/*::, length*/) { return data.read_shift(8, 'f'); }
158155
function write_Xnum(data, o) { return (o || new_buf(8)).write_shift(8, data, 'f'); }
159156

160-
/* [MS-XLSB] 2.5.198.2 */
157+
/* [MS-XLSB] 2.5.97.2 */
161158
var BErr = {
162159
/*::[*/0x00/*::]*/: "#NULL!",
163160
/*::[*/0x07/*::]*/: "#DIV/0!",
@@ -171,7 +168,7 @@ var BErr = {
171168
};
172169
var RBErr = evert_num(BErr);
173170

174-
/* [MS-XLSB] 2.4.321 BrtColor */
171+
/* [MS-XLSB] 2.4.324 BrtColor */
175172
function parse_BrtColor(data/*::, length*/) {
176173
var out = {};
177174
var d = data.read_shift(1);

bits/29_xlsenum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ var XLSFillPattern = [
184184
function rgbify(arr) { return arr.map(function(x) { return [(x>>16)&255,(x>>8)&255,x&255]; }); }
185185

186186
/* [MS-XLS] 2.5.161 */
187-
/* [MS-XLSB] 2.5.75 */
187+
/* [MS-XLSB] 2.5.75 Icv */
188188
var XLSIcv = rgbify([
189189
/* Color Constants */
190190
0x000000,

bits/30_ctype.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* Parts enumerated in OPC spec, MS-XLSB and MS-XLSX */
22
/* 12.3 Part Summary <SpreadsheetML> */
33
/* 14.2 Part Summary <DrawingML> */
4-
/* [MS-XLSX] 2.1 Part Enumerations */
5-
/* [MS-XLSB] 2.1.7 Part Enumeration */
4+
/* [MS-XLSX] 2.1 Part Enumerations ; [MS-XLSB] 2.1.7 Part Enumeration */
65
var ct2type/*{[string]:string}*/ = ({
76
/* Workbook */
87
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": "workbooks",

0 commit comments

Comments
 (0)