Welcome to the ASP.NET MVC feedback portal. We’re happy you’re here! If you have feedback on how to improve the ASP.NET MVC, we’d love to hear it!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

1
Vote

Hi,

I get an System.FormatException: Input string was not in a correct format, when using AutoFitColumns method.


Example code:

ExcelEngine engine = new ExcelEngine();
IWorkbook workbook = engine.Excel.Workbooks.Create(1);
workbook.Version = ExcelVersion.Excel2013;
IWorksheet sheet = workbook.Worksheets[0];
sheet[1, 1].DateTime = new DateTime(2017, 11, 14, 15, 59, 34, 788); sheet.Range[1,1].NumberFormat = "dd.mm.yyyy hh:mm";
sheet.Columns[0].AutofitColumns();

Exception StackTrace:

System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at Syncfusion.XlsIO.Implementation.WorksheetImpl.ConvertSecondsMinutesToHours(String value, Double dNumber)
   at Syncfusion.XlsIO.FormatParser.FormatSection.ApplyFormat(Double value, Boolean bShowReservedSymbols, RangeImpl cell)
   at Syncfusion.XlsIO.Implementation.RangeImpl.GetNumberOrDateTime(FormatImpl formatImpl, Double dValue, Int32 row, Int32 column)
   at Syncfusion.XlsIO.Implementation.RangeImpl.GetDisplayText(Int32 row, Int32 column, FormatImpl formatImpl)
   at Syncfusion.XlsIO.Implementation.AutoFitManager.MeasureToFitColumn()
  
at Syncfusion.XlsIO.Implementation.RangeImpl.AutoFitToColumn(Int32 firstColumn, Int32 lastColumn)