I am trying to read a XLS file using 'XLSX' node-module with a column having dates. After parsing the file what I found is that the dates are of few dates back from that of the dates in the sheet. This is what I a doing.
var workbook = XLSX.readFile(filePath);
var grossPayoutSheet = workbook.Sheets[worksheets[1]];
for (var i in grossPayoutSheet) {
if (i[0] === "!") continue;
var col = (!isNaN(parseInt(i.substring(1)))) ? i.substring(0,1) : i.substring(0,2);
var row = (!isNaN(parseInt(i.substring(1)))) ? parseInt(i.substring(1)) : parseInt(i.substring(2));
var value = grossPayoutSheet[i].v;
if (row === 2) {
var value = grossPayoutSheet[i].v;
headers[col] = value.trim();
continue;
}
if (row !== 1 && !data[row]) {
data[row] = {};
} else if (row !== 1){
data[row][headers[col]] = value;
}
}
the value in the cell B3 is
05/07/2017
but after parsing the value is
B3: { t: 'n', v: 42921, w: '42921' }
I want the date in string format that is I want to change the cell format from 'n' to 's'
Can anyone please me out with this?
const workbook = excel.readFile(file.path);
const sheet_name_list = workbook.SheetNames;
const json = excel.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]], {
raw: false,
});
var workbook = XLSX.read(data, {
type: 'binary',
cellDates: true,
cellNF: false,
cellText: false
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With