Bug with ImportDataTable method


#1

Hi,

I’m trying to test how long it takes Aspose.Excel to import a record set of this dimension: 464 rows and 41 columns ( 19024 records in total). But when I try to set the max number of rows and columns of the data table to be 1000, I get an “out of range” error. This is the line of code I used: Excel1.Worksheets[0].Cells.ImportDataTable(_dataTable, true, 0, 0,1000,1000, true); Even when I changed the numbers to be 100 columns and 500 rows, it doesn’t work.
Did you set an upper limit for the number of rows and columns allowed for a datable import? We really need this method to be able to handle huge datasets. Can you please give me feedback ASAP on this issue? Thank you.
Here’s the error I got:

Server Error in ‘/ExcelTest’ Application.

Specified argument was out of the range of valid values.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

Source Error:

Line 41: //Cell Cell1 = Excel1.Worksheets[0].Cells; Line 42: Line 43: Excel1.Worksheets[0].Cells.ImportDataTable(_dataTable, true, 0, 0,100,500, true); Line 44: NumofColumns=_dataTable.Columns.Count; Line 45: NumofRows=_dataTable.Rows.Count;

Source File: c:\inetpub\wwwroot\exceltest\code\aspose_excel.cs Line: 43

Stack Trace:

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.] Aspose.Excel.Cells.ImportDataTable(DataTable dataTable, Boolean isFieldNameShown, Int32 firstRow, Byte firstColumn, Int32 maxRows, Int32 maxColumns, Boolean insertRows, String numberFormatString) +1327 Aspose.Excel.Cells.ImportDataTable(DataTable dataTable, Boolean isFieldNameShown, Int32 firstRow, Byte firstColumn, Int32 maxRows, Int32 maxColumns, Boolean insertRows) +34 AsposePrototype.Aspose_Excel.ExportToExcel() in c:\inetpub\wwwroot\exceltest\code\aspose_excel.cs:43 AsposePrototype.WebForm1.ExcelExport_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\exceltest\webform1.aspx.cs:122 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1292 

#2

public int ImportDataTable(DataTable dataTable, bool isFieldNameShown, int firstRow, byte firstColumn, int maxRows, int maxColumns, bool insertRows)

maxColumns cannot be larger than 256. You code should be:

Excel1.Worksheets[0].Cells.ImportDataTable(_dataTable, true, 0, 0,1000,100, true);


#3

Thanks for you quick response. I got it working now.