Files
ferrovia-panel/scripts/generate_example_xlsx.js
2026-08-25 01:23:13 +02:00

17 lines
536 B
JavaScript

const XLSX = require('xlsx');
const fs = require('fs');
const path = require('path');
const csvPath = path.join(__dirname, '..', 'public', 'horaires_example.csv');
const outPath = path.join(__dirname, '..', 'public', 'horaires_example.xlsx');
if (!fs.existsSync(csvPath)) {
throw new Error(`CSV example not found: ${csvPath}`);
}
const csvContent = fs.readFileSync(csvPath, 'utf8');
const workbook = XLSX.read(csvContent, { type: 'string', raw: false, FS: ',' });
XLSX.writeFile(workbook, outPath);
console.log('Wrote', outPath);