We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Grid export to PDF or Excel, after grouping, filtering gives an error

Hi, how to export the filtered or grouped grid.

When I do this it give me an error, is this a big, I am using your sample code from the demos

Server Error in '/' Application.

String was not recognized as a valid DateTime.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.FormatException: String was not recognized as a valid DateTime.

Source Error:

Line 120:            GridProperties obj = ConvertGridObject(GridModel);
Line 121:
Line 122:            exp.Export(obj, DataSource, "Export.pdf", false, false, "flat-saffron");
Line 123:
Line 124:        }

Source File: C:\\Controllers\GridExportrController.cs Line:122

Stack Trace:

[FormatException: String was not recognized as a valid DateTime.]
   System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +11626318
   System.Convert.ToDateTime(String value) +83
   Syncfusion.EJ.Export.GridPdfExport.RenderGroupedRows(GroupResult context, Int32 groupLevel) +658
   Syncfusion.EJ.Export.GridPdfExport.<RenderGroupedData>b__8(GroupResult i) +46
   Syncfusion.Linq.FunctionalExtensions.ForEach(IEnumerable`1 items, Action`1 action) +146
   Syncfusion.EJ.Export.GridPdfExport.RenderGroupedData() +88
   Syncfusion.EJ.Export.GridPdfExport.ProcessGridContents() +94


thanks



3 Replies

RU Ragavee U S Syncfusion Team January 13, 2016 09:10 AM UTC

Hi Megatron,

Thanks for your interest in Syncfusion products.

We are able to reproduce the reported issue in the below scenario.

Scenario: When grouping a column with type “date” and exporting the grid. The Column type is defined as “string” in class definition and “date” in column definition. If the column has incorrect date format eg. 13-14/15, upon exporting, the reported exception occurs.

So please ensure if the scenario in your project corresponds to the same scenario as mentioned above. If so, we suggest you to provide proper dateTime format to the corresponding column.

For your convenience, we have created a sample to export grouped grid, which can be downloaded from the below location.

Sample Link: http://www.syncfusion.com/downloads/support/forum/121650/ze/Sample_Exporting1237505845

Regards,
Ragavee U S.


ME Megatron January 15, 2016 11:02 PM UTC

Thanks, that fixed it.  Can you please update the control, so the exported dataset is better formatted/aligned with a header option to insert the name of the grid with the operations performed (let these be overrides to add a header name).

It would be so much easier with some information, in its current state the alignment and the data exported is hard to read by the user.


RU Ragavee U S Syncfusion Team January 18, 2016 09:00 AM UTC

Hi Megatron,

Thanks for your update.

We have inbuilt exporting server side events support to customize a particular row/cell. Please refer to the following online documentation for more information on the Exporting Server side event handlers.

http://help.syncfusion.com/aspnetmvc/grid/exporting#exporting-server-events

Similarly, we can also append comments to the exported file. Please refer to the below documentation for more information.

Documentation Link: http://www.syncfusion.com/downloads/support/forum/121650/ze/Adding_comments_while_exporting-423099094

For your convenience, we have created a sample to add custom headers to the exported pdf document, which can be downloaded from the below location.

Sample Link: http://www.syncfusion.com/downloads/support/forum/121650/ze/Sample_Exporting_with_headers-530975413

Regards,
Ragavee U S.

Loader.
Up arrow icon