Skip to content

Commit a373597

Browse files
committed
version bump 0.18.9
1 parent 08f5678 commit a373597

19 files changed

+3349
-580
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ This log is intended to keep track of backwards-incompatible changes, including
44
but not limited to API changes and file location changes. Minor behavioral
55
changes may not be included if they are not expected to break existing code.
66

7+
## v0.18.9
8+
9+
* XLSX / ODS write defined names
10+
* sync defined names to AutoFilter setting on export
11+
* 1904 date system setting properly roundtripped
12+
* ODS read/write number formats
13+
714
## v0.18.8
815

916
* Plaintext parsing of dateless meridien time values (`1:23:45 PM`)

bits/01_version.js

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

bits/62_fxls.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ function stringify_formula(formula/*Array<any>*/, range, cell/*:any*/, supbooks,
10411041
}
10421042
}
10431043
if(stack.length > 1 && opts.WTF) throw new Error("bad formula stack");
1044+
if(stack[0] == "TRUE") return true; if(stack[0] == "FALSE") return false;
10441045
return stack[0];
10451046
}
10461047

bits/63_fbin.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ function write_XLSBFormulaErr(val/*:number*/) {
152152
oint.write_shift(4, 0);
153153
return oint;
154154
}
155+
/* Writes a PtgBool */
156+
function write_XLSBFormulaBool(val/*:boolean*/) {
157+
var oint = new_buf(10);
158+
oint.write_shift(4, 2);
159+
oint.write_shift(1, 0x1D);
160+
oint.write_shift(1, val?1:0);
161+
oint.write_shift(4, 0);
162+
return oint;
163+
}
155164

156165
/* Writes a PtgStr */
157166
function write_XLSBFormulaStr(val/*:string*/) {
@@ -306,7 +315,9 @@ function write_XLSBFormulaArea3D(_str, wb) {
306315

307316

308317
/* General Formula */
309-
function write_XLSBFormula(val/*:string*/, wb) {
318+
function write_XLSBFormula(val/*:string|number*/, wb) {
319+
if(typeof val == "number") return write_XLSBFormulaNum(val);
320+
if(typeof val == "boolean") return write_XLSBFormulaBool(val);
310321
if(/^#(DIV\/0!|GETTING_DATA|N\/A|NAME\?|NULL!|NUM!|REF!|VALUE!)$/.test(val)) return write_XLSBFormulaErr(+RBErr[val]);
311322
if(val.match(/^\$?(?:[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D]|[A-Z]{1,2})\$?(?:10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6]|[1-9]\d{0,5})$/)) return write_XLSBFormulaRef(val);
312323
if(val.match(/^\$?(?:[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D]|[A-Z]{1,2})\$?(?:10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6]|[1-9]\d{0,5}):\$?(?:[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D]|[A-Z]{1,2})\$?(?:10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6]|[1-9]\d{0,5})$/)) return write_XLSBFormulaRange(val);

bits/80_parseods.js

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,6 @@ function parse_text_p(text/*:string*//*::, tag*/)/*:Array<any>*/ {
1212
return [v];
1313
}
1414

15-
var number_formats_ods = {
16-
/* ods name: [short ssf fmt, long ssf fmt] */
17-
day: ["d", "dd"],
18-
month: ["m", "mm"],
19-
year: ["y", "yy"],
20-
hours: ["h", "hh"],
21-
minutes: ["m", "mm"],
22-
seconds: ["s", "ss"],
23-
"am-pm": ["A/P", "AM/PM"],
24-
"day-of-week": ["ddd", "dddd"],
25-
era: ["e", "ee"],
26-
/* there is no native representation of LO "Q" format */
27-
quarter: ["\\Qm", "m\\\"th quarter\""]
28-
};
29-
3015
/* Note: ODS can stick styles in content.xml or styles.xml, FODS blurs lines */
3116
function parse_ods_styles(d/*:string*/, _opts, _nfm) {
3217
var number_format_map = _nfm || {};
@@ -232,7 +217,7 @@ function parse_ods_styles(d/*:string*/, _opts, _nfm) {
232217
if(parsexmlbool(y["grouping"])) tNF = commaify(fill("#", Math.max(0, 4 - tNF.length)) + tNF);
233218
if(+y["min-decimal-places"] || +y["decimal-places"]) tNF += ".";
234219
if(+y["min-decimal-places"]) tNF += fill("0", +y["min-decimal-places"] || 1);
235-
if(+y["decimal-places"] - (+y["min-decimal-places"]||0)) tNF += fill("#", +y["decimal-places"] - (+y["min-decimal-places"]||0));
220+
if(+y["decimal-places"] - (+y["min-decimal-places"]||0)) tNF += fill("0", +y["decimal-places"] - (+y["min-decimal-places"]||0)); // TODO: should this be "#" ?
236221
NF += tNF;
237222
break;
238223

@@ -531,12 +516,7 @@ function parse_content_xml(d/*:string*/, _opts, _nfm)/*:Workbook*/ {
531516
case 'table-cell-properties': break; // 17.18 <style:table-cell-properties>
532517

533518
case 'number': // 16.27.3 <number:number>
534-
switch(state[state.length-1][0]) {
535-
case 'time-style':
536-
case 'date-style':
537-
tag = parsexmltag(Rn[0], false);
538-
NF += number_formats_ods[Rn[3]][tag.style==='long'?1:0]; break;
539-
} break;
519+
break;
540520

541521
case 'fraction': break; // TODO 16.27.6 <number:fraction>
542522

@@ -551,12 +531,7 @@ function parse_content_xml(d/*:string*/, _opts, _nfm)/*:Workbook*/ {
551531
case 'minutes': // 16.27.20 <number:minutes>
552532
case 'seconds': // 16.27.21 <number:seconds>
553533
case 'am-pm': // 16.27.22 <number:am-pm>
554-
switch(state[state.length-1][0]) {
555-
case 'time-style':
556-
case 'date-style':
557-
tag = parsexmltag(Rn[0], false);
558-
NF += number_formats_ods[Rn[3]][tag.style==='long'?1:0]; break;
559-
} break;
534+
break;
560535

561536
case 'boolean': break; // 16.27.24 <number:boolean>
562537
case 'text': // 16.27.26 <number:text>

dist/xlsx.core.min.js

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/xlsx.core.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)