Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Tue Dec 26, 2023 11:48 am

Exception Type : ArgumentOutOfRangeException
Error Message : Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Error Source : mscorlib
Error Trace : at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at Spire.Xls.Collections.WorksheetsCollection.get_Item(Int32 Index)
at dashboard_CRM_Entry_Report.ExporttoExcel(DataTable dt, DataTable dt1, DataTable dt2, DataTable dt3) in d:\FFW - 2021\dashboard\CRM_Entry_Report.aspx.cs:line 184

I got this messae while try to export data in excel with 4 diferent tab

Workbook book = new Workbook();
string filepath = "C:/Users/Fairmate/Downloads/";
string filename = "CRM Inquery on" + " " + DateTime.Now.ToString("dd/MMM/yyyy") + ".xlsx";
book.Worksheets[0].InsertDataTable(dt, true, 1, 1);
dt1 = crm.GetFollupDetail();
book.Worksheets[1].InsertDataTable(dt1, true, 1, 1);

dt1 = crm.GetOpenInquiry_With_FollupDetail();
book.Worksheets[2].InsertDataTable(dt1, true, 1, 1);

dt1 = crm.Get_Sample_Requisition_Inquiry_Detail(txtdate.Text, txttodate.Text);
book.Worksheets[3].InsertDataTable(dt1, true, 1, 1);

book.SaveToFile(filename, ExcelVersion.Version2016);

itexecutive12
 
Posts: 1
Joined: Tue Dec 26, 2023 10:57 am

Wed Dec 27, 2023 2:11 am

Hi,

Thank you for your inquiry.
Based on your information and description, I am not very clear about your needs. Please offer the following information to help us do further investigation. Thank you in advance.
1)Your test excel file, you can attach here or send it to us via email (support@e-iceblue.com).
2)Your full test code that can reproduce your issue.
3)Application type, such as Console App, .NET Framework 4.8.
4)Your test environment, such as OS info (E.g. Windows 7, 64-bit).

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Return to Spire.XLS