dtjohnson / xlsx-populate

Excel XLSX parser/generator written in JavaScript with Node.js and browser support, jQuery/d3-style method chaining, encryption, and a focus on keeping existing workbook features and styles in tact.
MIT License
956 stars 183 forks source link

how to read date as formatted date using usedRange() ? #357

Open prashantnirgun opened 1 year ago

prashantnirgun commented 1 year ago

I am reading data using range code is as follows. Column E contain date in dd/mm/yyyy format, but even if I specified style for that column it still read it as number. I think there should be option to set style and read range as formatted dates

const file = '/home/prashant/www/wa/wppconnect-server/uploads/excels/sample.xlsx';
const workbook = await reader.fromFileAsync(file);
const sheet = workbook.sheet(0);
sheet.column('E').style('numberFormat', 'dd/mm/yyyy');
const values = sheet.usedRange().value();
console.log(values);

it return date as

[
  [ "Name", "Date" ],
  [ "SaXXX",  29445 ],
  [ "Prashant", 27120 ],
  [ "Shreeyash", 33105  ]
]