I want to export all repeater data into excel file. I used this code but I got only one page data so I want to get all records (all pages).please help me.
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=Detail.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
rptrdata.RenderControl(htmlWrite);
Response.Write("");
");
Response.End();
Amit JagtapPosted Aug 20, 2015, 3:25 AM
Sumit JoshiPosted Aug 13, 2015, 7:17 AM
Rajeesh MenothPosted Aug 13, 2015, 6:58 AM
Hemlata KushwahaPosted Aug 13, 2015, 6:37 AM
");
");
");
");
");
Khan Abrar AhmedPosted Aug 13, 2015, 6:29 AM
{
Response.Clear();
Response.ContentType = "application/ms-excel"; //"application/vnd.xls";
Response.AddHeader("content-disposition", "attachment;filename=ServiceRequest.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
using (StringWriter sw = new StringWriter())
{
HtmlTextWriter hw = new HtmlTextWriter(sw);
//To Export all pages
gvServiceProcess.AllowPaging = false;
gvServiceProcess.HeaderRow.BackColor = System.Drawing.Color.Gray;
gvServiceProcess.HeaderRow.ForeColor = System.Drawing.Color.White;
foreach (TableCell cell in gvServiceProcess.HeaderRow.Cells)
{
cell.BackColor = gvServiceProcess.HeaderStyle.BackColor;
}
foreach (GridViewRow row in gvServiceProcess.Rows)
{
row.BackColor = System.Drawing.Color.White;
foreach (TableCell cell in row.Cells)
{
cell.HorizontalAlign = HorizontalAlign.Left;
cell.VerticalAlign = VerticalAlign.Top;
if (row.RowIndex % 2 == 0)
{
cell.BackColor = gvServiceProcess.AlternatingRowStyle.BackColor;
}
else
{
cell.BackColor = gvServiceProcess.RowStyle.BackColor;
}
cell.CssClass = "textmode";
}
}
gvServiceProcess.RenderControl(hw);
//style to format numbers to string
string style = @"";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
}
Nanhe SiddiquePosted Aug 13, 2015, 6:26 AM