HI:
I have implemented epplus export package in my VS 2012 project and it is working in all browsers except Firefox.
When I try to export gridview to excel in Firefox browser, it asks two options,
opens with and save
Excel is working in Opens With option.
But in save option, it is saving without file extension. I googled it, but no luck.
But I am able to export to excel in other browsers like IE, chrome.. but firefox not working.
Is there any solutions?
P.S: My Code is here
```
public static void ListToExcel<T>(List<T> query, string FileName)
{
HttpResponse Response = HttpContext.Current.Response;
using (ExcelPackage pck = new ExcelPackage())
{
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Result");
var t = typeof(T);
var Headings = t.GetProperties();
for (int i = 0; i < Headings.Count(); i++)
{
ws.Cells[1, i + 1].Value = Headings[i].Name;
}
if (query.Count() > 0)
{
ws.Cells["A2"].LoadFromCollection(query);
}
using (ExcelRange rng = ws.Cells[1, 1, 1, Headings.Count()])
{
rng.Style.Font.Bold = true;
rng.Style.Fill.PatternType = ExcelFillStyle.Solid;
rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(188, 31, 38));
rng.Style.Font.Color.SetColor(Color.White);
rng.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
}
//Write it back to the client
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment; filename=" + FileName + ".xlsx");
Response.BinaryWrite(pck.GetAsByteArray());
}
}
```
Thank you
I have implemented epplus export package in my VS 2012 project and it is working in all browsers except Firefox.
When I try to export gridview to excel in Firefox browser, it asks two options,
opens with and save
Excel is working in Opens With option.
But in save option, it is saving without file extension. I googled it, but no luck.
But I am able to export to excel in other browsers like IE, chrome.. but firefox not working.
Is there any solutions?
P.S: My Code is here
```
public static void ListToExcel<T>(List<T> query, string FileName)
{
HttpResponse Response = HttpContext.Current.Response;
using (ExcelPackage pck = new ExcelPackage())
{
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Result");
var t = typeof(T);
var Headings = t.GetProperties();
for (int i = 0; i < Headings.Count(); i++)
{
ws.Cells[1, i + 1].Value = Headings[i].Name;
}
if (query.Count() > 0)
{
ws.Cells["A2"].LoadFromCollection(query);
}
using (ExcelRange rng = ws.Cells[1, 1, 1, Headings.Count()])
{
rng.Style.Font.Bold = true;
rng.Style.Fill.PatternType = ExcelFillStyle.Solid;
rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(188, 31, 38));
rng.Style.Font.Color.SetColor(Color.White);
rng.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
}
//Write it back to the client
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment; filename=" + FileName + ".xlsx");
Response.BinaryWrite(pck.GetAsByteArray());
}
}
```
Thank you