xsheetjs/modules/numbers_to_csv.node.ts

18 lines
591 B
TypeScript
Raw Normal View History

2022-01-29 02:29:34 +00:00
#!/usr/bin/env ts-node
/*! sheetjs (C) 2013-present SheetJS -- http://sheetjs.com */
import { read } from 'cfb';
import { utils } from 'xlsx';
2022-03-21 01:39:16 +00:00
import { parse_numbers_iwa } from './src/numbers';
2022-01-29 02:29:34 +00:00
var f = process.argv[2];
var cfb = read(f, {type: "file"});
2022-03-21 01:39:16 +00:00
var wb = parse_numbers_iwa(cfb);
2022-01-29 02:29:34 +00:00
var sn = process.argv[3];
2022-01-31 11:40:30 +00:00
if(typeof sn == "undefined") {
wb.SheetNames.forEach(sn => console.log(utils.sheet_to_csv(wb.Sheets[sn])));
} else {
if(sn && !isNaN(+sn)) sn = wb.SheetNames[+sn];
if(wb.SheetNames.indexOf(sn) == -1) sn = wb.SheetNames[0];
console.log(utils.sheet_to_csv(wb.Sheets[sn]));
}