Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- `aoa_to_sheet` function (fixes #314 h/t @fonzy2013 @rvdwijngaard) - `writeFileAsync` function (fixes #396 h/t @barbalex) - `sheet_to_json` tests + docs + blankrows (fixes #602 h/t @EEaglehouse) - write number format scan now includes every index >= 50 - propagate SSF IE8 fixes (fixes #171 h/t @SheetJSDev) - update shim for extendscript (see #603 h/t @firas3d) - more flow type definitions
- Loading branch information
1 parent
60e8905
commit 70c48a7
Showing
22 changed files
with
464 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
function sheet_to_workbook(sheet/*:Worksheet*/, opts)/*:Workbook*/ { | ||
var n = opts && opts.sheet ? opts.sheet : "Sheet1"; | ||
var sheets = {}; sheets[n] = sheet; | ||
return { SheetNames: [n], Sheets: sheets }; | ||
} | ||
|
||
function aoa_to_sheet(data/*:AOA*/, opts/*:?any*/)/*:Worksheet*/ { | ||
var o = opts || {}; | ||
var ws/*:Worksheet*/ = ({}/*:any*/); | ||
var range/*:Range*/ = ({s: {c:10000000, r:10000000}, e: {c:0, r:0}}/*:any*/); | ||
for(var R = 0; R != data.length; ++R) { | ||
for(var C = 0; C != data[R].length; ++C) { | ||
if(typeof data[R][C] === 'undefined') continue; | ||
var cell/*:Cell*/ = ({v: data[R][C] }/*:any*/); | ||
if(range.s.r > R) range.s.r = R; | ||
if(range.s.c > C) range.s.c = C; | ||
if(range.e.r < R) range.e.r = R; | ||
if(range.e.c < C) range.e.c = C; | ||
var cell_ref = encode_cell(({c:C,r:R}/*:any*/)); | ||
if(cell.v === null) { if(!o.cellStubs) continue; cell.t = 'z'; } | ||
else if(typeof cell.v === 'number') cell.t = 'n'; | ||
else if(typeof cell.v === 'boolean') cell.t = 'b'; | ||
else if(cell.v instanceof Date) { | ||
cell.z = o.dateNF || SSF._table[14]; | ||
if(o.cellDates) cell.t = 'd'; | ||
else { cell.t = 'n'; cell.v = datenum(cell.v); } | ||
cell.w = SSF.format(cell.z, cell.v); | ||
} | ||
else cell.t = 's'; | ||
ws[cell_ref] = cell; | ||
} | ||
} | ||
if(range.s.c < 10000000) ws['!ref'] = encode_range(range); | ||
return ws; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,6 +167,7 @@ function xlml_normalize(d)/*:string*/ { | |
var xlmlregex = /<(\/?)([^\s?>!\/:]*:|)([^\s?>]*[^\s?>\/])[^>]*>/mg; | ||
//var xlmlregex = /<(\/?)([a-z0-9]*:|)(\w+)[^>]*>/mg; | ||
function parse_xlml_xml(d, opts)/*:Workbook*/ { | ||
make_ssf(SSF); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
SheetJSDev
Author
Contributor
|
||
var str = debom(xlml_normalize(d)); | ||
if(opts && opts.type == 'binary' && typeof cptable !== 'undefined') str = cptable.utils.decode(65001, char_codes(str)); | ||
if(str.substr(0,1000).indexOf("<html") >= 0) return parse_html(str, opts); | ||
|
@@ -277,7 +278,10 @@ function parse_xlml_xml(d, opts)/*:Workbook*/ { | |
break; | ||
|
||
case 'NumberFormat': | ||
stag.nf = xlml_parsexmltag(Rn[0]).Format || "General"; | ||
stag.nf = unescapexml(xlml_parsexmltag(Rn[0]).Format || "General"); | ||
if(XLMLFormatMap[stag.nf]) stag.nf = XLMLFormatMap[stag.nf]; | ||
for(var ssfidx = 0; ssfidx != 0x188; ++ssfidx) if(SSF._table[ssfidx] == stag.nf) break; | ||
if(ssfidx == 0x188) for(ssfidx = 0x39; ssfidx != 0x188; ++ssfidx) if(SSF._table[ssfidx] == null) { SSF.load(stag.nf, ssfidx); break; } | ||
break; | ||
|
||
case 'Column': | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
@SheetJSDev why adding the call of make_ssf? And there are several calls inside some bits files. The copied ssf library --
10_ssf.js
should be called once, shouldn't it? Or is it for resetting the SSF instance?