xsheetjs/bits/82_sheeter.js
SheetJS b9dae134f2 TXT/PRN
- UTF-16 Unicode Text (TXT) write
- Lotus Formatted Text (PRN) read/write
- DBF version 2 field length adjustments
- throw errors if SheetNames is invalid (fixes #376 h/t @pietersv)
2017-04-02 20:16:03 -04:00

16 lines
716 B
JavaScript

/* actual implementation elsewhere, wrappers are for read/write */
function write_obj_str(factory/*:WriteObjStrFactory*/) {
return function write_str(wb/*:Workbook*/, o/*:WriteOpts*/)/*:string*/ {
var idx = 0;
for(var i=0;i<wb.SheetNames.length;++i) if(wb.SheetNames[i] == o.sheet) idx=i;
if(idx == 0 && !!o.sheet && wb.SheetNames[0] != o.sheet) throw new Error("Sheet not found: " + o.sheet);
return factory.from_sheet(wb.Sheets[wb.SheetNames[idx]], o);
};
}
var write_csv_str = write_obj_str({from_sheet:sheet_to_csv});
var write_slk_str = write_obj_str(SYLK);
var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});