Hi Infragistics Team,
From database, we are getting date and we are displaying it in the grid like this -
{ headerText: "Entry Date", key: "ENTRY_DATE", dataType: "date" }
But, while exporting to excel we are getting NaN for Entry Date column.
however, we have tried cellexporting function but its not working .
Hello Tapas,
You could check if my previous suggestion is the cause of the issue by executing the following in your browser console when the grid is loaded:
$("#csagrid").data('igGrid').dataSource.dataView()[0]["ENTRY_DATE"]
If the value returned is a string, then it would make sense that it is exported as NaN in Excel. If this is the case, we'll have to figure out why your date column doesn't transform the strings coming from the server to JavaScript Date objects. You could try explicitly setting localSchemaTransform to true in your grid initialization code or observe the network tab in your browser developer tools to see the response you get when data binding. What are the values that come for the column 'ENTRY_DATE'?
I am also attaching a sample I created to see if I can reproduce this. The only NaN value that is shown in the Excel file for my sample is the first row's one which I deliberately made impossible to parse as a Date.
Best regards,
Stamen Stoychev
6136.sample.zip
nowhere we have set the localSchemaTransform .
We have tried with date format as well but nothing is working
For this date column to be exported as NaN in Excel, my guess is that its values in the grid's data source remain strings instead of getting converted to JavaScript Date objects. This can happen either because the server serialized values are not parsable by the browser (unlikely given the screenshot you provided) or because you set localSchemaTransform to false somewhere in your grid initialization code. Could you please check if this is the case and let me know.
Hi Stamen,
Below is my function which is getting called on export button click
$("#exportButton").on("igbuttonclick", function () { $.ig.GridExcelExporter.exportGrid($("#csagrid"), { fileName: "test" }, { dataExportMode: "allRows", exportEnding: function (e, args) { var columns = args.worksheet.columns(); columns.item(columns.count() - 1).cellFormat().formatString("dd/MMM/YYYY"); } });})
and below is the code where I am assigning data type as date for date column
columns: [
{ headerText: "CSA #", key: "CSA_NB", dataType: "string" }, { headerText: "Entry Date", key: "ENTRY_DATE", dataType: "date" }
]
It's hard to say what could be going wrong in this case based on the screenshots alone. In our Export to Excel sample we show a date column that is correctly exported. Could you please share a sample that reproduces the behavior that I could look at? Or check our sample for any differences that may result in this behavior.
I am looking forward to your reply. Thank you for using Infragistics forums!