forked from sheetjs/sheetjs
SheetJS
f43cacaf5e
- browser demo save file in global (fixes #573 h/t @WildDusk) - flesh out XLSB record expectations (fixes #624 h/t @pgeeh) - `dense` mode (fixes #34 h/t @schleumer)
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
/* [MS-XLSB] 2.4.219 BrtBeginSst */
|
|
function parse_BrtBeginSst(data, length) {
|
|
return [data.read_shift(4), data.read_shift(4)];
|
|
}
|
|
|
|
/* [MS-XLSB] 2.1.7.45 Shared Strings */
|
|
function parse_sst_bin(data, opts)/*:SST*/ {
|
|
var s/*:SST*/ = ([]/*:any*/);
|
|
var pass = false;
|
|
recordhopper(data, function hopper_sst(val, R, RT) {
|
|
switch(R.n) {
|
|
case 'BrtBeginSst': s.Count = val[0]; s.Unique = val[1]; break;
|
|
case 'BrtSSTItem': s.push(val); break;
|
|
case 'BrtEndSst': return true;
|
|
case 'BrtFRTBegin': pass = true; break;
|
|
case 'BrtFRTEnd': pass = false; break;
|
|
default: if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R.n);
|
|
}
|
|
});
|
|
return s;
|
|
}
|
|
|
|
function write_BrtBeginSst(sst, o) {
|
|
if(!o) o = new_buf(8);
|
|
o.write_shift(4, sst.Count);
|
|
o.write_shift(4, sst.Unique);
|
|
return o;
|
|
}
|
|
|
|
var write_BrtSSTItem = write_RichStr;
|
|
|
|
function write_sst_bin(sst, opts) {
|
|
var ba = buf_array();
|
|
write_record(ba, "BrtBeginSst", write_BrtBeginSst(sst));
|
|
for(var i = 0; i < sst.length; ++i) write_record(ba, "BrtSSTItem", write_BrtSSTItem(sst[i]));
|
|
/* FRTSST */
|
|
write_record(ba, "BrtEndSst");
|
|
return ba.end();
|
|
}
|