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.
Unfortunately, activation email could not send to your email. Please try again.

Export to Excel fails because of Decimal Format conversion error

Thread ID:

Created:

Updated:

Platform:

Replies:

130002 Apr 13,2017 03:19 PM Apr 18,2017 09:11 AM ASP.NET Core 1
loading
Tags: Grid
Romain Fabbri
Asked On April 13, 2017 03:19 PM

I'm using syncfusion version 15.1.41 (javascript) and 15.1600.0.41 (EJ and EJ Export)
When clicking on the Grid export Excel button I get a server side Exception :

StackTrace "   at System.Number.FormatDecimal(Decimal value, String format, NumberFormatInfo info)\r\n   at System.Decimal.ToString(String format, IFormatProvider provider)\r\n   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)\r\n   at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)\r\n   at System.String.Format(IFormatProvider provider, String format, Object[] args)\r\n   at Syncfusion.EJ.Export.GridExcelExport.ProcessRecordCell(Object row, Column column)\r\n   at System.Collections.Generic.List`1.ForEach(Action`1 action)\r\n   at Syncfusion.EJ.Export.GridExcelExport.ProcessRecordRow(Object row)\r\n   at Syncfusion.EJ.Export.GridExcelExport.RenderRecord()\r\n   at Syncfusion.EJ.Export.GridExcelExport.IterateElements()\r\n   at Syncfusion.EJ.Export.GridExcelExport.ExportHandler()\r\n   at Syncfusion.EJ.Export.GridExcelExport.Export(GridProperties gridModel, Object dataSource)\r\n   at summer_game_2017.Controllers.GameController.ExportToExcel(String GridModel) in C:\\Projets\\test\\test\\Controllers\\GameController.cs:line 59\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__27.MoveNext()" string

System.FormatException : 'Format specifier was invalid.'
+ $exception {System.FormatException: Format specifier was invalid.
   at System.Number.FormatDecimal(Decimal value, String format, NumberFormatInfo info)
   at System.Decimal.ToString(String format, IFormatProvider provider)
   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at Syncfusion.EJ.Export.GridExcelExport.ProcessRecordCell(Object row, Column column)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Syncfusion.EJ.Export.GridExcelExport.ProcessRecordRow(Object row)
   at Syncfusion.EJ.Export.GridExcelExport.RenderRecord()
   at Syncfusion.EJ.Export.GridExcelExport.IterateElements()
   at Syncfusion.EJ.Export.GridExcelExport.ExportHandler()
   at Syncfusion.EJ.Export.GridExcelExport.Export(GridProperties gridModel, Object dataSource)
   at summer_game_2017.Controllers.GameController.ExportToExcel(String GridModel) in C:\Projects\test\test\Controllers\GameController.cs:line 59
   at lambda_method(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__27.MoveNext()} System.FormatException


Mani Sankar Durai [Syncfusion]
Replied On April 18, 2017 09:11 AM

Hi Romain, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we suspect that you are trying to set the decimal format for the grid column value while exporting. Normal in grid we have set the formats based on Jquery Globalization. Based on that the format value will set for the grid column value. Here {0:D} format in jquery globalize will tends to date format. So to set the decimal point for the grid column value we suggest you to set the Format as {0:N2} property of columns in grid. 
Refer the code example. 
<ej-grid id="FlatGrid" allow-sorting="true" allow-paging="true"> 
     <e-columns> 
        <e-column field="Freight" header-text="Freight" format="{0:N2}" text-align=Right width="75"></e-column> 
        ... 
    </e-columns> 
</ej-grid> 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;