31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
|
|
const XLSX = require('xlsx');
|
||
|
|
const fs = require('fs');
|
||
|
|
const path = process.argv[2] || require('path').join(__dirname, 'Act_osmotr_103.xlsx');
|
||
|
|
const outPath = require('path').join(__dirname, 'act_output.txt');
|
||
|
|
|
||
|
|
let out = '';
|
||
|
|
function log(...args) { const s = args.join(' '); out += s + '\n'; console.log(...args); }
|
||
|
|
|
||
|
|
if (!fs.existsSync(path)) {
|
||
|
|
log('File not found:', path);
|
||
|
|
log('Copy Act_osmotr_103 (1).xlsx to backend folder and run: node read_act_xlsx.js');
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
|
||
|
|
const wb = XLSX.readFile(path);
|
||
|
|
log('=== SHEETS ===');
|
||
|
|
wb.SheetNames.forEach((name, i) => log(i, name));
|
||
|
|
|
||
|
|
wb.SheetNames.forEach((name) => {
|
||
|
|
log('\n=== SHEET:', name, '===');
|
||
|
|
const ws = wb.Sheets[name];
|
||
|
|
const ref = ws['!ref'] || 'A1';
|
||
|
|
const range = XLSX.utils.decode_range(ref);
|
||
|
|
log('Range:', ref, 'rows', range.e.r - range.s.r + 1, 'cols', range.e.c - range.s.c + 1);
|
||
|
|
const data = XLSX.utils.sheet_to_json(ws, { header: 1, defval: '' });
|
||
|
|
data.slice(0, 150).forEach((row, i) => log(JSON.stringify(row)));
|
||
|
|
});
|
||
|
|
|
||
|
|
fs.writeFileSync(outPath, out, 'utf8');
|
||
|
|
console.log('Written to', outPath);
|