"Input string was not in a correct format" when opening a file. It opens fine when once it is opened in windows and resave it as is

I converted the PDFs to Excels and now I am trying to extract the data from excel. When I try to open the workbook with Aspose.cells , its giving me an error “Input string was not in a correct format”

Tried to save as xls and as xlsx as well and same error. Trying to open in different methods yet having the same issue.

Opened this file manually and resaved it without any changes and it works both with Aspose fine.

Not sure if I a missing a step in conversion. Can you please suggest?

Code to convert PDF to xls:
Document pdfDocument = new Document(FileName);
Aspose.Pdf.ExcelSaveOptions excelsave = new ExcelSaveOptions();
excelsave.Format = ExcelSaveOptions.ExcelFormat.XLSX;
string outputExcelFileName = FileName.Replace(".pdf", “.xls”).Replace(FilePath, “”);
pdfDocument.Save(Extract.GetDataDir_ExcelOutput() + outputExcelFileName, excelsave);

Code to read excel:
Workbook Currworkbook = new Workbook(FileName);
Currworkbook.FileName = FileName;
Currworkbook.FileFormat = FileFormatType.Xlsx;
Worksheet Currsheet = Currworkbook.Worksheets[“Sheet4”];

@avasireddy,
You may share your sample PDF file and output Excel file. We will reproduce the issue here and share our feedback.

P.S. Please ensure that the latest versions are used for testing.

Attached is the pdf file.
TransitHistory.pdf (18.0 KB)

@avasireddy

We tested the scenario using Aspose.PDF for .NET 20.12 and Aspose.Cells for .NET 20.12 in our environment and were not able to notice any issue. The code did not raise any issues. Would you please make sure to use the latest versions of the APIs and let us know in case you still face any issue?

I have 20.11 which is pretty latest. Do you want me to try with 20.12?

@avasireddy

It is recommended to use the latest available version of the APIs as we provide support on the basis of its usage. Yes, please try using 20.12 version of both APIs and let us know in case you encounter any issue.

The issue is resolved after I upgraded to the latest version (20.12). Thank you!

1 Like