I am getting date columns as general type in excel
I am getting date columns as general type in excel
{
extend: 'excelHtml5',
title: pg_name,
exportOptions: {
columns: ':not(.no-print):visible',
orthogonal: null,
format: {
body: function (data, row, column, node) {
var $node = $(node);
if ($node.find("span.clsColsDateStr").length) {
$node.find("span.clsColsDateStr").remove();
}
var text = $node.text().trim();
var m = moment(text, ['DD-MMM-YYYY'], true);
if (m.isValid()) {
return m.format('YYYY-MM-DD');
}
return text || "";
}
}
},
customize: function (xlsx) {
}
}
Answers
Can you link to a test case showing the issue please? ISO8061 formatted date strings should be dates in Excel after the export.
Allan
Inserting date values into Excel can be tricky. The internal storage format is number of days since
1899-12-30T00:00:00Z.Based on that, my solution looks like this:
I am using Luxon rather than outdated moments.js. But I think, it should be no big deal to convert it.
Many thanks. Interesting to see how you've done it.
For interest, this is how Buttons does it. It only supports YYYY-MM-DD at the moment.
Allan