我正在尝试使用 npm 中的 XLSX 包创建一个 csv 文件,结果是用 , (冒号)分隔的值,我想用 ; (分号)。我该怎么办?
LSX.utils.book_append_sheet(workbook, worksheet, fileName);
const options = { cellDates: true };
const file = XLSX.writeFile(workbook, `${fileNameWithLocation}${extension}`, options);
文档链接:https://docs.sheetjs.com/docs/api/utilities/csv/
应该是这样的
const XLSX = require("xlsx");
const fs = require("fs");
const data = [
["Name", "Age", "Country"],
["Alice", 30, "Canada"],
["Bob", 25, "USA"],
["Charles, Jr.", 35, "UK"],
];
const worksheet = XLSX.utils.aoa_to_sheet(data);
let csv = XLSX.utils.sheet_to_csv(worksheet, { FS: ";" });
fs.writeFileSync("output.csv", csv);