Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2732
GridExcelExporting with Date formatting
posted

Hello,

I tried to export a grid with a date = '01/01/0001' which is actually a null value in our Oracle database.

When exporting the grid to Excel I see in that column that the date is mentioned as: "Mon Jan 01 1 01:00:00 GMT+0100 (Romance Standard Time)".

I have tried to alter the export method as follows:

cellExporting: function (e, args) {
if (args.columnKey == "expiryDate" && args.cellValue == "Mon Jan 01 1 01:00:00 GMT+0100 (Romance Standard Time)") {
args.xlRow.getCellFormat(args.columnIndex).font().bold(1);
args.xlRow.setCellValue(args.columnIndex, new Date(2055,1,1));
}
},

Above code is setting the date in bold for that specific row, but it is not changing the date as requested.

Is it possible to empty the date field?

I have also noted that in your fiddle example when I try to add a date column with a date = '01/01/0001' it shows in Excel as '01/01/2001' ?

http://jsfiddle.net/h7cw52y0/

Kind regards

Parents
No Data
Reply
  • 11095
    Verified Answer
    Offline posted

    Hello Michael,

    Thank you for contacting Infragistics!

    You can use cellExported instead so you cna modify the value of the exported cell.

    About the second issue, this is by design of JavaScript. The igGrid creates a object of type date, i.e. new Date("01/01/0001"), which is Mon Jan 01 1 01:00:00 GMT+0100 (Romance Standard Time). Note that is also impossible to set year of 1, since the lowest value of year is 1901.

     

Children
No Data