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);