version bump 0.10.8

- TS definition removed DOM references (fixes #724 h/t @shaunc)
- extendscript inconsistent processing of bitwise ops
- updated browser tests
This commit is contained in:
SheetJS 2017-07-10 18:18:18 -04:00
parent d28cc872c7
commit 6a913d3a7b
27 changed files with 231 additions and 120 deletions

View File

@ -1 +1 @@
XLSX.version = '0.10.7';
XLSX.version = '0.10.8';

View File

@ -86,7 +86,7 @@ var utf8read/*:StringConv*/ = function utf8reada(orig) {
c = orig.charCodeAt(i++);
if (c < 128) { out += String.fromCharCode(c); continue; }
d = orig.charCodeAt(i++);
if (c>191 && c<224) { out += String.fromCharCode(((c & 31) << 6) | (d & 63)); continue; }
if (c>191 && c<224) { f = ((c & 31) << 6); f |= (d & 63); out += String.fromCharCode(f); continue; }
e = orig.charCodeAt(i++);
if (c < 240) { out += String.fromCharCode(((c & 15) << 12) | ((d & 63) << 6) | (e & 63)); continue; }
f = orig.charCodeAt(i++);

View File

@ -41,6 +41,7 @@ function parse_ext_props(data, p) {
case "Worksheets":
case "工作表":
case "Листы":
case "أوراق العمل":
case "ワークシート":
case "גליונות עבודה":
case "Arbeitsblätter":

View File

@ -42,7 +42,7 @@ function parse_clrScheme(t, themes, opts) {
case '<a:accent6>': case '</a:accent6>':
case '<a:hlink>': case '</a:hlink>':
case '<a:folHlink>': case '</a:folHlink>':
if (y[0][1] === '/') {
if (y[0].charAt(1) === '/') {
themes.themeElements.clrScheme.push(color);
color = {};
} else {

View File

@ -364,7 +364,9 @@ return function parse_ws_xml_data(sdata, s, opts, guess, themes, styles) {
cf = styles.CellXf[tag.s];
if(cf != null) {
if(cf.numFmtId != null) fmtid = cf.numFmtId;
if(opts.cellStyles && cf.fillId != null) fillid = cf.fillId;
if(opts.cellStyles) {
if(cf.fillId != null) fillid = cf.fillId;
}
}
}
safe_format(p, fmtid, fillid, opts, themes, styles);

View File

@ -477,7 +477,7 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles)/*:Worksheet*/ {
break;
case 0x0001: /* 'BrtCellBlank' */
if(!opts.sheetStubs) break;
if(!opts.sheetStubs || pass) break;
p = ({t:'z',v:undefined}/*:any*/);
C = val[0].c;
if(opts.dense) { if(!s[R]) s[R] = []; s[R][C] = p; }
@ -543,6 +543,7 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles)/*:Worksheet*/ {
s['!margins'] = val;
break;
case 0x01E5: /* 'BrtWsFmtInfo' */
/* case 'BrtUid' */
case 0x00AF: /* 'BrtAFilterDateGroupItem' */
case 0x0284: /* 'BrtActiveX' */
@ -595,7 +596,6 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles)/*:Worksheet*/ {
case 0x00AA: /* 'BrtTop10Filter' */
case 0x0032: /* 'BrtValueMeta' */
case 0x0816: /* 'BrtWebExtension' */
case 0x01E5: /* 'BrtWsFmtInfo' */
case 0x0415: /* 'BrtWsFmtInfoEx14' */
case 0x0093: /* 'BrtWsProp' */
break;

View File

@ -139,6 +139,9 @@ function parse_wb_xml(data, opts)/*:WorkbookFile*/ {
case '<AlternateContent': pass=true; break;
case '</AlternateContent>': pass=false; break;
/* TODO */
case '<revisionPtr': break;
default: if(!pass && opts.WTF) throw new Error('unrecognized ' + y[0] + ' in workbook');
}
return x;

View File

@ -100,6 +100,9 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
supbooks.SheetNames.push(val.name);
wb.Sheets.push(val); break;
case 0x0099: /* 'BrtWbProp' */
wb.WBProps = val; break;
case 0x0027: /* 'BrtName' */
val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
delete val.Ptg;
@ -107,8 +110,13 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
break;
case 0x040C: /* 'BrtNameExt' */ break;
case 0x0099: /* 'BrtWbProp' */
wb.WBProps = val; break;
case 0x0165: /* 'BrtSupSelf' */
case 0x0166: /* 'BrtSupSame' */
case 0x0163: /* 'BrtSupBookSrc' */
case 0x029B: /* 'BrtSupAddin' */
case 0x016A: /* 'BrtExternSheet' */
case 0x0169: /* 'BrtPlaceholderName' */
break;
/* case 'BrtModelTimeGroupingCalcCol' */
/* case 'BrtRevisionPtr' */
@ -120,7 +128,6 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
case 0x009D: /* 'BrtCalcProp' */
case 0x0262: /* 'BrtCrashRecErr' */
case 0x0802: /* 'BrtDecoupledPivotCacheID' */
case 0x016A: /* 'BrtExternSheet' */
case 0x009B: /* 'BrtFileRecover' */
case 0x0224: /* 'BrtFileSharing' */
case 0x02A4: /* 'BrtFileSharingIso' */
@ -130,12 +137,7 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
case 0x084D: /* 'BrtModelTable' */
case 0x0225: /* 'BrtOleSize' */
case 0x0805: /* 'BrtPivotTableRef' */
case 0x0169: /* 'BrtPlaceholderName' */
case 0x0254: /* 'BrtSmartTagType' */
case 0x029B: /* 'BrtSupAddin' */
case 0x0163: /* 'BrtSupBookSrc' */
case 0x0166: /* 'BrtSupSame' */
case 0x0165: /* 'BrtSupSelf' */
case 0x081C: /* 'BrtTableSlicerCacheID' */
case 0x081B: /* 'BrtTableSlicerCacheIDs' */
case 0x0822: /* 'BrtTimelineCachePivotCacheID' */

View File

@ -288,7 +288,7 @@ var XLSBRecordEnum = {
/*::[*/0x0160/*::]*/: { n:"BrtListTrFmla", f:parsenoop },
/*::[*/0x0161/*::]*/: { n:"BrtBeginExternals", f:parsenoop },
/*::[*/0x0162/*::]*/: { n:"BrtEndExternals", f:parsenoop },
/*::[*/0x0163/*::]*/: { n:"BrtSupBookSrc", f:parsenoop },
/*::[*/0x0163/*::]*/: { n:"BrtSupBookSrc", f:parse_RelID},
/*::[*/0x0165/*::]*/: { n:"BrtSupSelf", f:parsenoop },
/*::[*/0x0166/*::]*/: { n:"BrtSupSame", f:parsenoop },
/*::[*/0x0167/*::]*/: { n:"BrtSupTabs", f:parsenoop },

1
demos/angular2/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
dist

28
dist/xlsx.core.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

28
dist/xlsx.full.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

83
dist/xlsx.js vendored
View File

@ -6,7 +6,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.10.7';
XLSX.version = '0.10.8';
var current_codepage = 1200;
/*global cptable:true */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -1681,7 +1681,7 @@ var utf8read = function utf8reada(orig) {
c = orig.charCodeAt(i++);
if (c < 128) { out += String.fromCharCode(c); continue; }
d = orig.charCodeAt(i++);
if (c>191 && c<224) { out += String.fromCharCode(((c & 31) << 6) | (d & 63)); continue; }
if (c>191 && c<224) { f = ((c & 31) << 6); f |= (d & 63); out += String.fromCharCode(f); continue; }
e = orig.charCodeAt(i++);
if (c < 240) { out += String.fromCharCode(((c & 15) << 12) | ((d & 63) << 6) | (e & 63)); continue; }
f = orig.charCodeAt(i++);
@ -3350,6 +3350,7 @@ function parse_ext_props(data, p) {
case "Worksheets":
case "工作表":
case "Листы":
case "أوراق العمل":
case "ワークシート":
case "גליונות עבודה":
case "Arbeitsblätter":
@ -4230,6 +4231,8 @@ function parse_Row(blob, length) {
blob.l += 4; // reserved(2), unused(2)
var flags = blob.read_shift(1); // various flags
blob.l += 3; // reserved(8), ixfe(12), flags(4)
if(flags & 0x07) z.level = flags & 0x07;
// collapsed: flags & 0x10
if(flags & 0x20) z.hidden = true;
if(flags & 0x40) z.hpt = miyRw / 20;
return z;
@ -5668,7 +5671,8 @@ var PRN = (function() {
function finish_cell() {
var s = str.slice(start, end);
var cell = ({});
if(s.charCodeAt(0) == 0x3D) { cell.t = 'n'; cell.f = s.substr(1); }
if(o.raw) { cell.t = 's'; cell.v = s; }
else if(s.charCodeAt(0) == 0x3D) { cell.t = 'n'; cell.f = s.substr(1); }
else if(s == "TRUE") { cell.t = 'b'; cell.v = true; }
else if(s == "FALSE") { cell.t = 'b'; cell.v = false; }
else if(!isNaN(v = +s)) { cell.t = 'n'; cell.w = s; cell.v = v; }
@ -5762,7 +5766,6 @@ function read_wb_ID(d, opts) {
return PRN.to_workbook(d, opts);
}
}
var WK_ = (function() {
function lotushopper(data, cb, opts) {
if(!data) return;
@ -7614,7 +7617,7 @@ function parse_clrScheme(t, themes, opts) {
case '<a:accent6>': case '</a:accent6>':
case '<a:hlink>': case '</a:hlink>':
case '<a:folHlink>': case '</a:folHlink>':
if (y[0][1] === '/') {
if (y[0].charAt(1) === '/') {
themes.themeElements.clrScheme.push(color);
color = {};
} else {
@ -10933,6 +10936,7 @@ return function parse_ws_xml_data(sdata, s, opts, guess, themes, styles) {
rowobj = {}; rowrite = false;
if(tag.ht) { rowrite = true; rowobj.hpt = parseFloat(tag.ht); rowobj.hpx = pt2px(rowobj.hpt); }
if(tag.hidden == "1") { rowrite = true; rowobj.hidden = true; }
if(tag.outlineLevel != null) { rowrite = true; rowobj.level = +tag.outlineLevel; }
if(rowrite) rows[tagr-1] = rowobj;
}
@ -11034,7 +11038,9 @@ return function parse_ws_xml_data(sdata, s, opts, guess, themes, styles) {
cf = styles.CellXf[tag.s];
if(cf != null) {
if(cf.numFmtId != null) fmtid = cf.numFmtId;
if(opts.cellStyles && cf.fillId != null) fillid = cf.fillId;
if(opts.cellStyles) {
if(cf.fillId != null) fillid = cf.fillId;
}
}
}
safe_format(p, fmtid, fillid, opts, themes, styles);
@ -11062,7 +11068,7 @@ function write_ws_xml_data(ws, opts, idx, wb, rels) {
if(_cell === undefined) continue;
if((cell = write_ws_xml_cell(_cell, ref, ws, opts, idx, wb)) != null) r.push(cell);
}
if(r.length > 0) {
if(r.length > 0 || rows && rows[R]) {
var params = ({r:rr});
if(rows && rows[R]) {
var row = rows[R];
@ -11071,10 +11077,24 @@ function write_ws_xml_data(ws, opts, idx, wb, rels) {
if (row.hpx) height = px2pt(row.hpx);
else if (row.hpt) height = row.hpt;
if (height > -1) { params.ht = height; params.customHeight = 1; }
if (row.level) { params.outlineLevel = row.level; }
}
o[o.length] = (writextag('row', r.join(""), params));
}
}
if(rows) for(; R < rows.length; ++R) {
if(rows && rows[R]) {
var params = ({r:R+1});
var row = rows[R];
if(row.hidden) params.hidden = 1;
var height = -1;
if (row.hpx) height = px2pt(row.hpx);
else if (row.hpt) height = row.hpt;
if (height > -1) { params.ht = height; params.customHeight = 1; }
if (row.level) { params.outlineLevel = row.level; }
o[o.length] = (writextag('row', "", params));
}
}
return o.join("");
}
@ -11100,7 +11120,11 @@ function write_ws_xml(idx, opts, wb, rels) {
o[o.length] = write_ws_xml_sheetviews(ws, opts, idx, wb);
/* TODO: store in WB, process styles */
if(opts.sheetFormat) o[o.length] = (writextag('sheetFormatPr', null, {defaultRowHeight:opts.sheetFormat.defaultRowHeight||'16', baseColWidth:opts.sheetFormat.baseColWidth||'10' }));
if(opts.sheetFormat) o[o.length] = (writextag('sheetFormatPr', null, {
defaultRowHeight:opts.sheetFormat.defaultRowHeight||'16',
baseColWidth:opts.sheetFormat.baseColWidth||'10',
outlineLevelRow:opts.sheetFormat.outlineLevelRow||'7'
}));
if(ws['!cols'] != null && ws['!cols'].length > 0) o[o.length] = (write_ws_xml_cols(ws, ws['!cols']));
@ -11194,6 +11218,7 @@ function parse_BrtRowHdr(data, length) {
data.l += 1; // TODO: top/bot padding
var flags = data.read_shift(1);
data.l = tgt;
if(flags & 0x07) z.level = flags & 0x07;
if(flags & 0x10) z.hidden = true;
if(flags & 0x20) z.hpt = miyRw / 20;
return z;
@ -11213,6 +11238,7 @@ function write_BrtRowHdr(R, range, ws) {
o.write_shift(1, 0); /* top/bot padding */
var flags = 0x0;
if(row.level) flags |= row.level;
if(row.hidden) flags |= 0x10;
if(row.hpx || row.hpt) flags |= 0x20;
o.write_shift(1, flags);
@ -11247,7 +11273,7 @@ function write_BrtRowHdr(R, range, ws) {
}
function write_row_header(ba, ws, range, R) {
var o = write_BrtRowHdr(R, range, ws);
if(o.length > 17) write_record(ba, 'BrtRowHdr', o);
if(o.length > 17 || (ws['!rows']||[])[R]) write_record(ba, 'BrtRowHdr', o);
}
/* [MS-XLSB] 2.4.812 BrtWsDim */
@ -11610,7 +11636,7 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles) {
if(opts.sheetRows && opts.sheetRows <= row.r) end=true;
rr = encode_row(R = row.r);
opts['!row'] = row.r;
if(val.hidden || val.hpt) {
if(val.hidden || val.hpt || val.level != null) {
if(val.hpt) val.hpx = pt2px(val.hpt);
rowinfo[val.r] = val;
}
@ -11659,7 +11685,7 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles) {
break;
case 0x0001: /* 'BrtCellBlank' */
if(!opts.sheetStubs) break;
if(!opts.sheetStubs || pass) break;
p = ({t:'z',v:undefined});
C = val[0].c;
if(opts.dense) { if(!s[R]) s[R] = []; s[R][C] = p; }
@ -11725,6 +11751,7 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles) {
s['!margins'] = val;
break;
case 0x01E5: /* 'BrtWsFmtInfo' */
/* case 'BrtUid' */
case 0x00AF: /* 'BrtAFilterDateGroupItem' */
case 0x0284: /* 'BrtActiveX' */
@ -11777,7 +11804,6 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles) {
case 0x00AA: /* 'BrtTop10Filter' */
case 0x0032: /* 'BrtValueMeta' */
case 0x0816: /* 'BrtWebExtension' */
case 0x01E5: /* 'BrtWsFmtInfo' */
case 0x0415: /* 'BrtWsFmtInfoEx14' */
case 0x0093: /* 'BrtWsProp' */
break;
@ -11868,12 +11894,14 @@ function write_CELLTABLE(ba, ws, idx, opts, wb) {
var range = safe_decode_range(ws['!ref'] || "A1"), ref, rr = "", cols = [];
write_record(ba, 'BrtBeginSheetData');
var dense = Array.isArray(ws);
for(var R = range.s.r; R <= range.e.r; ++R) {
var cap = range.e.r;
if(ws['!rows']) cap = Math.max(range.e.r, ws['!rows'].length - 1);
for(var R = range.s.r; R <= cap; ++R) {
rr = encode_row(R);
/* [ACCELLTABLE] */
/* BrtRowHdr */
write_row_header(ba, ws, range, R);
for(var C = range.s.c; C <= range.e.c; ++C) {
if(R <= range.e.r) for(var C = range.s.c; C <= range.e.c; ++C) {
/* *16384CELL */
if(R === range.s.r) cols[C] = encode_col(C);
ref = cols[C] + rr;
@ -12412,6 +12440,9 @@ function parse_wb_xml(data, opts) {
case '<AlternateContent': pass=true; break;
case '</AlternateContent>': pass=false; break;
/* TODO */
case '<revisionPtr': break;
default: if(!pass && opts.WTF) throw new Error('unrecognized ' + y[0] + ' in workbook');
}
return x;
@ -12598,6 +12629,9 @@ function parse_wb_bin(data, opts) {
supbooks.SheetNames.push(val.name);
wb.Sheets.push(val); break;
case 0x0099: /* 'BrtWbProp' */
wb.WBProps = val; break;
case 0x0027: /* 'BrtName' */
val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
delete val.Ptg;
@ -12605,8 +12639,13 @@ function parse_wb_bin(data, opts) {
break;
case 0x040C: /* 'BrtNameExt' */ break;
case 0x0099: /* 'BrtWbProp' */
wb.WBProps = val; break;
case 0x0165: /* 'BrtSupSelf' */
case 0x0166: /* 'BrtSupSame' */
case 0x0163: /* 'BrtSupBookSrc' */
case 0x029B: /* 'BrtSupAddin' */
case 0x016A: /* 'BrtExternSheet' */
case 0x0169: /* 'BrtPlaceholderName' */
break;
/* case 'BrtModelTimeGroupingCalcCol' */
/* case 'BrtRevisionPtr' */
@ -12618,7 +12657,6 @@ function parse_wb_bin(data, opts) {
case 0x009D: /* 'BrtCalcProp' */
case 0x0262: /* 'BrtCrashRecErr' */
case 0x0802: /* 'BrtDecoupledPivotCacheID' */
case 0x016A: /* 'BrtExternSheet' */
case 0x009B: /* 'BrtFileRecover' */
case 0x0224: /* 'BrtFileSharing' */
case 0x02A4: /* 'BrtFileSharingIso' */
@ -12628,12 +12666,7 @@ function parse_wb_bin(data, opts) {
case 0x084D: /* 'BrtModelTable' */
case 0x0225: /* 'BrtOleSize' */
case 0x0805: /* 'BrtPivotTableRef' */
case 0x0169: /* 'BrtPlaceholderName' */
case 0x0254: /* 'BrtSmartTagType' */
case 0x029B: /* 'BrtSupAddin' */
case 0x0163: /* 'BrtSupBookSrc' */
case 0x0166: /* 'BrtSupSame' */
case 0x0165: /* 'BrtSupSelf' */
case 0x081C: /* 'BrtTableSlicerCacheID' */
case 0x081B: /* 'BrtTableSlicerCacheIDs' */
case 0x0822: /* 'BrtTimelineCachePivotCacheID' */
@ -14450,6 +14483,7 @@ wb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;
} break;
case 'Row': {
var rowobj = {};
if(val.level != null) { rowinfo[val.r] = rowobj; rowobj.level = val.level; }
if(val.hidden) { rowinfo[val.r] = rowobj; rowobj.hidden = true; }
if(val.hpt) {
rowinfo[val.r] = rowobj;
@ -15055,7 +15089,7 @@ var XLSBRecordEnum = {
0x0160: { n:"BrtListTrFmla", f:parsenoop },
0x0161: { n:"BrtBeginExternals", f:parsenoop },
0x0162: { n:"BrtEndExternals", f:parsenoop },
0x0163: { n:"BrtSupBookSrc", f:parsenoop },
0x0163: { n:"BrtSupBookSrc", f:parse_RelID},
0x0165: { n:"BrtSupSelf", f:parsenoop },
0x0166: { n:"BrtSupSame", f:parsenoop },
0x0167: { n:"BrtSupTabs", f:parsenoop },
@ -16570,6 +16604,9 @@ var parse_content_xml = (function() {
case 'forms': break; // 12.25.2 13.2
case 'table-column': break; // 9.1.6 <table:table-column>
/* TODO: outline levels */
case 'table-row-group': break; // 9.1.9 <table:table-row-group>
case 'table-column-group': break; // 9.1.10 <table:table-column-group>
case 'null-date': break; // 9.4.2 <table:null-date> TODO: date1904

28
dist/xlsx.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.min.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "xlsx",
"version": "0.10.7",
"version": "0.10.8",
"author": "sheetjs",
"description": "Excel (XLSB/XLSX/XLS/XML) ODS and other spreadsheet format (CSV/DIF/DBF/SYLK) parser and writer",
"keywords": [ "excel", "xls", "xlsx", "xlsb", "xlsm", "ods", "csv", "dbf", "dif", "sylk", "office", "spreadsheet" ],

View File

@ -29,6 +29,7 @@ number_format.xlsb
number_format_entities.xlsb
number_format_russian.xlsb
numfmt_1_russian.xlsb
outline.xlsb
phonetic_text.xlsb
pivot_table_named_range.xlsb
pivot_table_test.xlsb
@ -362,6 +363,7 @@ openpyxl_r_formulae.xlsx
openpyxl_r_nonstandard_workbook_name.xlsx
openpyxl_r_null_archive.xlsx.pending
openpyxl_r_null_file.xlsx.pending
outline.xlsx
phonetic_text.xlsx
pivot_table_named_range.xlsx
rich_text_stress.xlsx
@ -553,6 +555,7 @@ cell_style_simple.ods
formula_stress_test.ods
merge_cells.ods
number_format.ods
outline.ods
rich_text_stress.ods
roo_numbers1.ods
roo_type_excel.ods
@ -1198,6 +1201,7 @@ number_format.xls
number_format_entities.xls
number_format_russian.xls
numfmt_1_russian.xls
outline.xls
phonetic_text.xls
phpexcel_bad_cfb_dir.xls
pivot_table_named_range.xls
@ -1371,6 +1375,10 @@ xlsx-stream-d-date-cell.xlsx.xml
2013/apachepoi_54016.xls.xlsb
2013/apachepoi_ReadOnlyRecommended.xls.xlsb
2013/apachepoi_testArraysAndTables.xls.xlsb
column_width.biff5
outline.biff5
row_height.biff5
sized_boxen.biff5
artifacts/quattro/write_.csv
artifacts/quattro/write_.dif
artifacts/quattro/write_.slk

View File

@ -92,6 +92,12 @@ var paths = {
nfxlsx: dir + 'number_format.xlsm',
nfxlsb: dir + 'number_format.xlsb',
olxls: dir + 'outline.xls',
olxls5: dir + 'outline.biff5',
olxlsx: dir + 'outline.xlsx',
olxlsb: dir + 'outline.xlsb',
olods: dir + 'outline.ods',
pmxls: dir + 'page_margins_2016.xls',
pmxls5: dir + 'page_margins_2016_5.xls',
pmxml: dir + 'page_margins_2016.xml',
@ -896,6 +902,7 @@ describe('parse features', function() {
describe('row properties', function() {
var wb1, wb2, wb3, wb4, wb5, wb6;
var ol1, ol2, ol3, ol4, ol5;
var bef = (function() {
X = require(modp);
wb1 = X.read(fs.readFileSync(paths.rhxlsx), {type:"binary", cellStyles:true});
@ -904,6 +911,11 @@ describe('parse features', function() {
wb4 = X.read(fs.readFileSync(paths.rhxls5), {type:"binary", cellStyles:true});
wb5 = X.read(fs.readFileSync(paths.rhxml), {type:"binary", cellStyles:true});
wb6 = X.read(fs.readFileSync(paths.rhslk), {type:"binary", cellStyles:true});
ol1 = X.read(fs.readFileSync(paths.olxlsx), {type:"binary", cellStyles:true});
ol2 = X.read(fs.readFileSync(paths.olxlsb), {type:"binary", cellStyles:true});
ol3 = X.read(fs.readFileSync(paths.olxls), {type:"binary", cellStyles:true});
ol4 = X.read(fs.readFileSync(paths.olxls5), {type:"binary", cellStyles:true});
ol5 = X.read(fs.readFileSync(paths.olods), {type:"binary", cellStyles:true});
});
if(typeof before != 'undefined') before(bef);
else it('before', bef);
@ -925,6 +937,22 @@ describe('parse features', function() {
assert.equal(x[3].hpx, 100);
});
});
it('should have correct outline levels', function() {
/* TODO: ODS */
[ol1, ol2, ol3, ol4/*, ol5*/].map(function(x) { return x.Sheets.Sheet1; }).forEach(function(ws) {
var rows = ws['!rows'];
for(var i = 0; i < 29; ++i) {
var cell = get_cell(ws, "A" + X.utils.encode_row(i));
var lvl = (rows[i]||{}).level||0;
if(!cell || cell.t == 's') assert.equal(lvl, 0);
else if(cell.t == 'n') {
if(cell.v == 0) assert.equal(lvl, 0);
else assert.equal(lvl, cell.v);
}
}
assert.equal(rows[29].level, 7);
});
});
});
describe('merge cells',function() {
@ -1395,18 +1423,21 @@ describe('roundtrip features', function() {
}); });
});
/* TODO: ODS and BIFF5/8 */
describe('should preserve row properties', function() { [
'xlml', /*'biff2', */ 'xlsx', 'xlsb', 'slk'
].forEach(function(w) { it(w, function() {
var ws1 = X.utils.aoa_to_sheet([["hpx12"],["hpt24"],["hpx48"],["hidden"]]);
ws1['!rows'] = [{hpx:12},{hpt:24},{hpx:48},{hidden:true}];
for(var i = 0; i <= 7; ++i) ws1['!rows'].push({level:i});
var wb1 = {SheetNames:["Sheet1"], Sheets:{Sheet1:ws1}};
var wb2 = X.read(X.write(wb1, {bookType:w, type:"binary"}), {type:"binary", cellStyles:true});
var wb2 = X.read(X.write(wb1, {bookType:w, type:"binary", cellStyles:true}), {type:"binary", cellStyles:true});
var ws2 = wb2.Sheets.Sheet1;
assert.equal(ws2['!rows'][0].hpx, 12);
assert.equal(ws2['!rows'][1].hpt, 24);
assert.equal(ws2['!rows'][2].hpx, 48);
assert.equal(ws2['!rows'][3].hidden, true);
if(w == 'xlsb' || w == 'xlsx') for(i = 0; i <= 7; ++i) assert.equal((ws2['!rows'][4+i]||{}).level||0, i);
}); });
});

File diff suppressed because one or more lines are too long

View File

@ -50,6 +50,11 @@
./test_files/number_format.xls.xml
./test_files/number_format.xlsm
./test_files/number_format.xlsb
./test_files/outline.xls
./test_files/outline.biff5
./test_files/outline.xlsx
./test_files/outline.xlsb
./test_files/outline.ods
./test_files/page_margins_2016.xls
./test_files/page_margins_2016_5.xls
./test_files/page_margins_2016.xml

View File

@ -30,7 +30,7 @@ fs.readdirSync = function(p) { return Object.keys(fs).filter(function(n) {
return fs.hasOwnProperty(n) && n.slice(-4) != "Sync"; });
};
fs.readFileSync = function(f, enc) {
if(!fs[f]) throw "File not found: " + f;
if(!fs[f]) throw new Error("File not found: " + f);
fs[f].length;
switch(enc) {
case 'base64': return fs[f];

6
types/index.d.ts vendored
View File

@ -620,9 +620,9 @@ export interface XLSX$Utils {
json_to_sheet<T>(data: T[], opts?: JSON2SheetOpts): WorkSheet;
json_to_sheet(data: any[], opts?: JSON2SheetOpts): WorkSheet;
/** Converts a TABLE DOM element to a worksheet. */
table_to_sheet(data: HTMLTableElement, opts?: Table2SheetOpts): WorkSheet;
table_to_book(data: HTMLTableElement, opts?: Table2SheetOpts): WorkBook;
/** BROWSER ONLY! Converts a TABLE DOM element to a worksheet. */
table_to_sheet(data: any, opts?: Table2SheetOpts): WorkSheet;
table_to_book(data: any, opts?: Table2SheetOpts): WorkBook;
/* --- Export Functions --- */

View File

@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [ "es5", "dom" ],
"lib": [ "es5" ],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,

View File

@ -6,7 +6,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.10.7';
XLSX.version = '0.10.8';
var current_codepage = 1200;
/*:: declare var cptable:any; */
/*global cptable:true */
@ -1733,7 +1733,7 @@ var utf8read/*:StringConv*/ = function utf8reada(orig) {
c = orig.charCodeAt(i++);
if (c < 128) { out += String.fromCharCode(c); continue; }
d = orig.charCodeAt(i++);
if (c>191 && c<224) { out += String.fromCharCode(((c & 31) << 6) | (d & 63)); continue; }
if (c>191 && c<224) { f = ((c & 31) << 6); f |= (d & 63); out += String.fromCharCode(f); continue; }
e = orig.charCodeAt(i++);
if (c < 240) { out += String.fromCharCode(((c & 15) << 12) | ((d & 63) << 6) | (e & 63)); continue; }
f = orig.charCodeAt(i++);
@ -3410,6 +3410,7 @@ function parse_ext_props(data, p) {
case "Worksheets":
case "工作表":
case "Листы":
case "أوراق العمل":
case "ワークシート":
case "גליונות עבודה":
case "Arbeitsblätter":
@ -7681,7 +7682,7 @@ function parse_clrScheme(t, themes, opts) {
case '<a:accent6>': case '</a:accent6>':
case '<a:hlink>': case '</a:hlink>':
case '<a:folHlink>': case '</a:folHlink>':
if (y[0][1] === '/') {
if (y[0].charAt(1) === '/') {
themes.themeElements.clrScheme.push(color);
color = {};
} else {
@ -11103,7 +11104,9 @@ return function parse_ws_xml_data(sdata, s, opts, guess, themes, styles) {
cf = styles.CellXf[tag.s];
if(cf != null) {
if(cf.numFmtId != null) fmtid = cf.numFmtId;
if(opts.cellStyles && cf.fillId != null) fillid = cf.fillId;
if(opts.cellStyles) {
if(cf.fillId != null) fillid = cf.fillId;
}
}
}
safe_format(p, fmtid, fillid, opts, themes, styles);
@ -11749,7 +11752,7 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles)/*:Worksheet*/ {
break;
case 0x0001: /* 'BrtCellBlank' */
if(!opts.sheetStubs) break;
if(!opts.sheetStubs || pass) break;
p = ({t:'z',v:undefined}/*:any*/);
C = val[0].c;
if(opts.dense) { if(!s[R]) s[R] = []; s[R][C] = p; }
@ -11815,6 +11818,7 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles)/*:Worksheet*/ {
s['!margins'] = val;
break;
case 0x01E5: /* 'BrtWsFmtInfo' */
/* case 'BrtUid' */
case 0x00AF: /* 'BrtAFilterDateGroupItem' */
case 0x0284: /* 'BrtActiveX' */
@ -11867,7 +11871,6 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles)/*:Worksheet*/ {
case 0x00AA: /* 'BrtTop10Filter' */
case 0x0032: /* 'BrtValueMeta' */
case 0x0816: /* 'BrtWebExtension' */
case 0x01E5: /* 'BrtWsFmtInfo' */
case 0x0415: /* 'BrtWsFmtInfoEx14' */
case 0x0093: /* 'BrtWsProp' */
break;
@ -12504,6 +12507,9 @@ function parse_wb_xml(data, opts)/*:WorkbookFile*/ {
case '<AlternateContent': pass=true; break;
case '</AlternateContent>': pass=false; break;
/* TODO */
case '<revisionPtr': break;
default: if(!pass && opts.WTF) throw new Error('unrecognized ' + y[0] + ' in workbook');
}
return x;
@ -12691,6 +12697,9 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
supbooks.SheetNames.push(val.name);
wb.Sheets.push(val); break;
case 0x0099: /* 'BrtWbProp' */
wb.WBProps = val; break;
case 0x0027: /* 'BrtName' */
val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
delete val.Ptg;
@ -12698,8 +12707,13 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
break;
case 0x040C: /* 'BrtNameExt' */ break;
case 0x0099: /* 'BrtWbProp' */
wb.WBProps = val; break;
case 0x0165: /* 'BrtSupSelf' */
case 0x0166: /* 'BrtSupSame' */
case 0x0163: /* 'BrtSupBookSrc' */
case 0x029B: /* 'BrtSupAddin' */
case 0x016A: /* 'BrtExternSheet' */
case 0x0169: /* 'BrtPlaceholderName' */
break;
/* case 'BrtModelTimeGroupingCalcCol' */
/* case 'BrtRevisionPtr' */
@ -12711,7 +12725,6 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
case 0x009D: /* 'BrtCalcProp' */
case 0x0262: /* 'BrtCrashRecErr' */
case 0x0802: /* 'BrtDecoupledPivotCacheID' */
case 0x016A: /* 'BrtExternSheet' */
case 0x009B: /* 'BrtFileRecover' */
case 0x0224: /* 'BrtFileSharing' */
case 0x02A4: /* 'BrtFileSharingIso' */
@ -12721,12 +12734,7 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
case 0x084D: /* 'BrtModelTable' */
case 0x0225: /* 'BrtOleSize' */
case 0x0805: /* 'BrtPivotTableRef' */
case 0x0169: /* 'BrtPlaceholderName' */
case 0x0254: /* 'BrtSmartTagType' */
case 0x029B: /* 'BrtSupAddin' */
case 0x0163: /* 'BrtSupBookSrc' */
case 0x0166: /* 'BrtSupSame' */
case 0x0165: /* 'BrtSupSelf' */
case 0x081C: /* 'BrtTableSlicerCacheID' */
case 0x081B: /* 'BrtTableSlicerCacheIDs' */
case 0x0822: /* 'BrtTimelineCachePivotCacheID' */
@ -15155,7 +15163,7 @@ var XLSBRecordEnum = {
/*::[*/0x0160/*::]*/: { n:"BrtListTrFmla", f:parsenoop },
/*::[*/0x0161/*::]*/: { n:"BrtBeginExternals", f:parsenoop },
/*::[*/0x0162/*::]*/: { n:"BrtEndExternals", f:parsenoop },
/*::[*/0x0163/*::]*/: { n:"BrtSupBookSrc", f:parsenoop },
/*::[*/0x0163/*::]*/: { n:"BrtSupBookSrc", f:parse_RelID},
/*::[*/0x0165/*::]*/: { n:"BrtSupSelf", f:parsenoop },
/*::[*/0x0166/*::]*/: { n:"BrtSupSame", f:parsenoop },
/*::[*/0x0167/*::]*/: { n:"BrtSupTabs", f:parsenoop },

38
xlsx.js
View File

@ -6,7 +6,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.10.7';
XLSX.version = '0.10.8';
var current_codepage = 1200;
/*global cptable:true */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -1681,7 +1681,7 @@ var utf8read = function utf8reada(orig) {
c = orig.charCodeAt(i++);
if (c < 128) { out += String.fromCharCode(c); continue; }
d = orig.charCodeAt(i++);
if (c>191 && c<224) { out += String.fromCharCode(((c & 31) << 6) | (d & 63)); continue; }
if (c>191 && c<224) { f = ((c & 31) << 6); f |= (d & 63); out += String.fromCharCode(f); continue; }
e = orig.charCodeAt(i++);
if (c < 240) { out += String.fromCharCode(((c & 15) << 12) | ((d & 63) << 6) | (e & 63)); continue; }
f = orig.charCodeAt(i++);
@ -3350,6 +3350,7 @@ function parse_ext_props(data, p) {
case "Worksheets":
case "工作表":
case "Листы":
case "أوراق العمل":
case "ワークシート":
case "גליונות עבודה":
case "Arbeitsblätter":
@ -7616,7 +7617,7 @@ function parse_clrScheme(t, themes, opts) {
case '<a:accent6>': case '</a:accent6>':
case '<a:hlink>': case '</a:hlink>':
case '<a:folHlink>': case '</a:folHlink>':
if (y[0][1] === '/') {
if (y[0].charAt(1) === '/') {
themes.themeElements.clrScheme.push(color);
color = {};
} else {
@ -11037,7 +11038,9 @@ return function parse_ws_xml_data(sdata, s, opts, guess, themes, styles) {
cf = styles.CellXf[tag.s];
if(cf != null) {
if(cf.numFmtId != null) fmtid = cf.numFmtId;
if(opts.cellStyles && cf.fillId != null) fillid = cf.fillId;
if(opts.cellStyles) {
if(cf.fillId != null) fillid = cf.fillId;
}
}
}
safe_format(p, fmtid, fillid, opts, themes, styles);
@ -11682,7 +11685,7 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles) {
break;
case 0x0001: /* 'BrtCellBlank' */
if(!opts.sheetStubs) break;
if(!opts.sheetStubs || pass) break;
p = ({t:'z',v:undefined});
C = val[0].c;
if(opts.dense) { if(!s[R]) s[R] = []; s[R][C] = p; }
@ -11748,6 +11751,7 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles) {
s['!margins'] = val;
break;
case 0x01E5: /* 'BrtWsFmtInfo' */
/* case 'BrtUid' */
case 0x00AF: /* 'BrtAFilterDateGroupItem' */
case 0x0284: /* 'BrtActiveX' */
@ -11800,7 +11804,6 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles) {
case 0x00AA: /* 'BrtTop10Filter' */
case 0x0032: /* 'BrtValueMeta' */
case 0x0816: /* 'BrtWebExtension' */
case 0x01E5: /* 'BrtWsFmtInfo' */
case 0x0415: /* 'BrtWsFmtInfoEx14' */
case 0x0093: /* 'BrtWsProp' */
break;
@ -12437,6 +12440,9 @@ function parse_wb_xml(data, opts) {
case '<AlternateContent': pass=true; break;
case '</AlternateContent>': pass=false; break;
/* TODO */
case '<revisionPtr': break;
default: if(!pass && opts.WTF) throw new Error('unrecognized ' + y[0] + ' in workbook');
}
return x;
@ -12623,6 +12629,9 @@ function parse_wb_bin(data, opts) {
supbooks.SheetNames.push(val.name);
wb.Sheets.push(val); break;
case 0x0099: /* 'BrtWbProp' */
wb.WBProps = val; break;
case 0x0027: /* 'BrtName' */
val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
delete val.Ptg;
@ -12630,8 +12639,13 @@ function parse_wb_bin(data, opts) {
break;
case 0x040C: /* 'BrtNameExt' */ break;
case 0x0099: /* 'BrtWbProp' */
wb.WBProps = val; break;
case 0x0165: /* 'BrtSupSelf' */
case 0x0166: /* 'BrtSupSame' */
case 0x0163: /* 'BrtSupBookSrc' */
case 0x029B: /* 'BrtSupAddin' */
case 0x016A: /* 'BrtExternSheet' */
case 0x0169: /* 'BrtPlaceholderName' */
break;
/* case 'BrtModelTimeGroupingCalcCol' */
/* case 'BrtRevisionPtr' */
@ -12643,7 +12657,6 @@ function parse_wb_bin(data, opts) {
case 0x009D: /* 'BrtCalcProp' */
case 0x0262: /* 'BrtCrashRecErr' */
case 0x0802: /* 'BrtDecoupledPivotCacheID' */
case 0x016A: /* 'BrtExternSheet' */
case 0x009B: /* 'BrtFileRecover' */
case 0x0224: /* 'BrtFileSharing' */
case 0x02A4: /* 'BrtFileSharingIso' */
@ -12653,12 +12666,7 @@ function parse_wb_bin(data, opts) {
case 0x084D: /* 'BrtModelTable' */
case 0x0225: /* 'BrtOleSize' */
case 0x0805: /* 'BrtPivotTableRef' */
case 0x0169: /* 'BrtPlaceholderName' */
case 0x0254: /* 'BrtSmartTagType' */
case 0x029B: /* 'BrtSupAddin' */
case 0x0163: /* 'BrtSupBookSrc' */
case 0x0166: /* 'BrtSupSame' */
case 0x0165: /* 'BrtSupSelf' */
case 0x081C: /* 'BrtTableSlicerCacheID' */
case 0x081B: /* 'BrtTableSlicerCacheIDs' */
case 0x0822: /* 'BrtTimelineCachePivotCacheID' */
@ -15081,7 +15089,7 @@ var XLSBRecordEnum = {
0x0160: { n:"BrtListTrFmla", f:parsenoop },
0x0161: { n:"BrtBeginExternals", f:parsenoop },
0x0162: { n:"BrtEndExternals", f:parsenoop },
0x0163: { n:"BrtSupBookSrc", f:parsenoop },
0x0163: { n:"BrtSupBookSrc", f:parse_RelID},
0x0165: { n:"BrtSupSelf", f:parsenoop },
0x0166: { n:"BrtSupSame", f:parsenoop },
0x0167: { n:"BrtSupTabs", f:parsenoop },