Click here to Skip to main content
15,792,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m exporting grid view data in excel on button clicked
in grid view have 1000 records so when I clicked export to excel button then I getting error
the excel sheet is not reading. reading problem and also takeing time.
how to do ?
plz help me
MT_ 22-Aug-14 11:16am    
What are you using? How are you exporting? Are you using InterOp, third party library? Some form of more details and possible code snippet would help others to help you.
sadhana4 22-Aug-14 13:15pm    
public void exportRequest()
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Work Schedule.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);

grdvwOverdueWorkOrders.AllowPaging = false;
grdvwOverdueWorkOrders.AllowSorting = false;
grdvwOverdueWorkOrders.Columns[0].Visible = false;
grdvwOverdueWorkOrders.Columns[3].Visible = false;
grdvwOverdueWorkOrders.Columns[1].ItemStyle.Width = 150;
grdvwOverdueWorkOrders.Columns[2].ItemStyle.Width = 150;
grdvwOverdueWorkOrders.Columns[5].ItemStyle.Width = 150;
grdvwOverdueWorkOrders.Columns[6].ItemStyle.Width = 100;
grdvwOverdueWorkOrders.Columns[7].ItemStyle.Width = 100;
grdvwOverdueWorkOrders.Columns[8].ItemStyle.Width = 100;

grdvwOverdueWorkOrders.Columns[9].ItemStyle.Width = 100;
grdvwOverdueWorkOrders.Columns[10].ItemStyle.Width = 150;
grdvwOverdueWorkOrders.Columns[12].ItemStyle.Width = 150;
grdvwOverdueWorkOrders.Columns[14].ItemStyle.Width = 150;
grdvwOverdueWorkOrders.Columns[16].ItemStyle.Width = 150;
//Change the Header Row back to white color
grdvwOverdueWorkOrders.HeaderRow.Style.Add("background-color", "#FFFFFF");
//Applying stlye to gridview header cells
for (int i = 0; i < grdvwOverdueWorkOrders.HeaderRow.Cells.Count; i++)
grdvwOverdueWorkOrders.HeaderRow.Cells[i].Style.Add("background-color", "#df5015");

sadhana4 22-Aug-14 13:19pm    
I have 1000 records but when I exporting to excel .I am getting error. I am not able to read the records in excel sheet after exported gridviewdata
sadhana4 22-Aug-14 13:19pm    
plz help me

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900