My code works 99% of the time, but I have this one .xls file that continues to throw this error, "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" on this line...
Well, If we use your template file and execute your code, we get the same error message as you mentioned, But by just resaving your template file in MS Excel and testing it with your provided sample application, it works fine. Did you generated this template file using Aspose.Cells? If yes, please share your code and we will look into it and also your provided template file to figure out the issue. Also, now Aspose.Cells provides direct conversion of Excel files to PDF (without converting to XML and using Aspose.PDF APIs), please see the following sample code in this regard,
Sample Code:
//Instantiate the Workbook object
Workbook myWorkbook = new Workbook();
//Open the workbook
myWorkbook.Open("C:\\Input.xls");
//Save the document in PDF format
myWorkbook.Save("C:\\output.pdf", FileFormatType.Pdf);
Unfortunately, I do have the luxury of opening and resaving the .xls as the is being pocessed from an email attachment in a Windows service. I did not create the .xls with Aspose.Cells - it was created bywhoever attache it to the email.
I did try your suggestion of the streamlined conversion from .xls to .pdf. However, the FileFormatTpe of Pdf (i.e. myWorkbook.Save("C:\\output.pdf", FileFormatType.Pdf);) is not available in type-ahead - see screenshot.) I am using Aspose.Cells version 4.6.0.0.....What was the earliest Aspose.Cells version that supports the more direct conversion from .xls to .pdf? It seems like I just upgraded our Aspose.Total package a couple of weeks ago.
We will check you template file for the index out of range issue and provide you with a fix soon. For FileFormatType.PDF, it was supported after the official release 4.6.0.0, so you may require the latest fix to use this functionality. I have attached the latest fix in case you want to check for this new functionality.
Thank you for your prompt response. I tried the latest Aspose.Cell.dll (version 4.6.0.16) that you sent. Although I like the new streamlined conversion (and I have implemented the newer version in my actual project), it still throws the index error. I will await your fix for this.
Good morning, I have the same problem. When I save my workbook I get the same error.
Perform a first successful rescue, then perform spreadsheet operations, and apply the formulacalculate method and the second rescue process fails.
I use aspose version 7.
As you are using some older version (v7.0.0) of the product for which I am not sure about your issue. Neither we can evaluate your issue with older version that you are using. We recommend you to kindly upgrade to and try our latest version/fix:
Aspose.Cells for .NET v17.7:
Aspose.Cells for Java v17.7
If you still find the issue with v17.7, kindly create a sample console application (runnable), zip the project and post us here with all the files, we will check it soon.