I have a select option value as
<select id="FilterOptions" role="ListBox">
<option value="7">1 Week</option>
<option value="14">2 Week</option>
<option value="28">4 Week</option>
<option value="90">2 Months</option>
<option value="182">6 Months</option>
<option value="365">All</option>
</select>
I have an Icon to export to excel and below is the functionality.
My JqGrid works fine with all the option. But here is the problem. After Selecting ALL and All records are loaded without any error. But after exporting to excel I receive "Object Reference not set to an instance on the line specified below"
How can I solve this error?
public string ExportReport(int cp, int noOfOrders)
{
string conndb=ConfigurationManager.AppSettings["Db"];
const string Ids ="0";
Company pList = _items.GetByCID(cp);
IQueryable<Product> List
List=product.SQLDatabase().GetListByCompandIds(cp, Convert.ToInt32(noOfOrders), conndb, Ids)
XLWorkbook workbook = new XLWorkbook(XLEventTracking.Disabled);
IXLWorksheet worksheet = workbook.Worksheets.Add("ExportReport");
worksheet.Cell(1, 1).Value = "Received";
worksheet.Cell(1, 2).Value = "Customer Email";
worksheet.Cell(1, 3).Value = "First Name";
worksheet.Cell(1, 4).Value = "Last Name";
worksheet.Cell(1, 5).Value = "Company Name";
worksheet.Cell(1, 6).Value = "Product Name";
int i = 2;
foreach (EReport ExpReport in List)
{
worksheet.Cell(i, 1).SetValue(ExpReport.received);
worksheet.Cell(i, 2).SetValue(ExpReport.Email);
worksheet.Cell(i, 3).SetValue(ExpReport.FirstName); // *Here is the line where I am receiving an error*
worksheet.Cell(i, 4).SetValue(ExpReport.LastName);
worksheet.Cell(i, 5).SetValue(ExpReport.CompanyName);
worksheet.Cell(i, 6).SetValue(ExpReport.ProductName);
++i;
}
worksheet.Columns().AdjustToContents();
Session["Workbook"] = workbook;
string filename;
filename = "Product-Report";
return filename;
}
- How to export with sorting with a specific column received?