问题描述
我正在此仓库中使用名为xlsx的npm软件包:
https://github.com/SheetJS/sheetjs
我正在运行带有cellDates选项:true,但我的输出仍然是数字格式。任何人都知道如何修改我的代码以将我的日期列解析为时间戳格式,或者将数字转换为字符串形式的日期,当我在excel文件中手动执行操作时,这似乎也起作用。
感谢帮助!
const xlsx = require('xlsx')
const excelToObjArr = (filePath) => {
const obj = xlsx.parse(filePath,{ 'type': type,cellDates: true }); // parses a file
const data = obj[0].data;
let dataObjects = [];
let tableAttrs = data[0];
for(let i=1; i < data.length; i++){
let newObj = {};
for(let j=0; j < tableAttrs.length; j++){
newObj[tableAttrs[j]] = data[i][j];
}
dataObjects.push(newObj);
}
return dataObjects;
};
module.exports = excelToObjArr;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)