Free Support Forum - aspose.com

ArgumentOutOfRangeException from ImportDataTable in 4.4.1.10

I have an existing application using Cells 4.2.0.0 that opens a 2003 format workbook that serves as a template of sorts, then puts new sheets and data into it and saves it. This resulting file could not be read in Excel 2007, so I have downloaded the latest version (4.4.1.10).

I had to adjust my source to change the way styles were attributed to ranges (rng.ApplyStyle(... replaces rng.Style = ...). I did that to get to a clean compile then ran my application.

Now I am getting an System.ArgumentOutOfRangeException thrown by ImportDataTable per the exception shown below.

Any thoughts on how ImportDataTable could throw index out of range?

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at Aspose.Cells.Cells.ImportDataTable(DataTable dataTable, Boolean isFieldNameShown, Int32 firstRow, Int32 firstColumn, Int32 rowNumber, Int32 columnNumber, Boolean insertRows, String dateFormatString, Boolean convertStringToNumber)
at Aspose.Cells.Cells.ImportDataTable(DataTable dataTable, Boolean isFieldNameShown, Int32 firstRow, Int32 firstColumn, Int32 rowNumber, Int32 columnNumber, Boolean insertRows, String dateFormatString)
at Aspose.Cells.Cells.ImportDataTable(DataTable dataTable, Boolean isFieldNameShown, Int32 firstRow, Int32 firstColumn, Int32 rowNumber, Int32 columnNumber, Boolean insertRows)
at ReportServer.CDistributionReport.GenerateSheets() in e:\development\bn\reportserver\reportserver_cs\cdistributionreport.cs:line 665
at ReportServer.CLossMitDistributionReport.GenerateSheets() in E:\Development\BN\ReportServer\ReportServer_CS\CLossMitDistributionReport.cs:line 48
at ReportServer.CDistributionReport.Generate() in e:\development\bn\reportserver\reportserver_cs\cdistributionreport.cs:line 74
at ReportServer.CDistributionReport.GenerateReport() in e:\development\bn\reportserver\reportserver_cs\cdistributionreport.cs:line 50
at ReportServer.ReportServer.Process(String appName, Int32 productionCycleId, String sourceNumber, String reportName) in e:\development\bn\reportserver\reportserver_cs\main.cs:line 242
at ReportServer.ReportServer.Main(String[] args) in e:\development\bn\reportserver\reportserver_cs\main.cs:line 69

I think you call this method:

Cells.ImportDataTable(DataTable dataTable, Boolean isFieldNameShown, Int32 firstRow, Int32 firstColumn, Int32 rowNumber, Int32 columnNumber, Boolean insertRows)

Please debug into your application to see the values of:

firstRow, firstColumn, rowNumber, columnNumber

And you can also try this attached fix.

This did not work. I have attached a very simple project that causes the problem.

Hi,

Thanks for providing us the sample project,

Well, since you are using some older version of Aspose.Cells (4.4.1), it might be some problem with ImportDataTable() method. I tried your project with the latest version / fix (4.4.3.8) and it works fine without any problem whatsoever.

Kindly try the attached version (4.4.3.8).

Thank you.