My data contains dates in microsoft json format /Date(1335205592410)/
The IgGrid nicely formats them automatically when I set the dataType to date.
When exporting to excel the sheet contains the json date. How could I format the date dd/mm/yyyy ? Is there a setting or do I have to write something in
cellExporting: function (e, args) {
if (args.columnKey == "MyDateField") {
..............
}
It's best to check the cell value first or you'll get a !#VALUE errorexportExcel() {
console.log('exporting to excel....');
jQuery.ig.GridExcelExporter.exportGrid(jQuery('#' + this.id), {
fileName: "export"
},
{
cellExported: function (e, args) {
if (args.xlRow.index() == 0)
return;
if (args.columnKey == "DateLastTransaction" || args.columnKey == "DateMaturity") {
var xlRow = args.xlRow;
if (args.cellValue)
xlRow.cells(args.columnIndex).applyFormula('=TEXT((MID("' + args.cellValue + '",7,10)/86400)+DATE(1970,1,1),"dd/mm/yyyy")');
});
It woudn't work on the cellExporting callback but it worked on the cellExported
if (args.xlRow.index() == 0) {
xlRow.cells(args.columnIndex).applyFormula('=TEXT((MID("' + args.cellValue + '",7,10)/86400)+DATE(1970,1,1),"dd/MM/yyyy")');
Hello Alan,
Thank you for contacting Infragistics!
To achieve the behavior you want on exporting you would have to apply the format in the cellExporting callback:
http://www.igniteui.com/help/api/2016.2/ig.gridexcelexporter#options:callbacks.cellExporting