Click here to Skip to main content
15,914,642 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to put Header(Date, Which type of Report Company Name) at top in Excel sheet Report .....Im exporting Excel sheet from C#.Net...My Code is below
C#
protected void btnExcel_Click1(object sender, ImageClickEventArgs e)
{
    Response.Clear();
    Response.AddHeader("Content-Disposition", "attachment;filename=AttandanceReport.xls");
    Response.Charset = "";
    Response.ContentType = "application/vnd.xls";
    System.IO.StringWriter stringWrite = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
    // grdreport1.BorderStyle = BorderStyle.Solid;
    // grdreport1.BorderWidth = 1;
    //   grdreport1.BackColor = Color.WhiteSmoke;
    // grdreport1.GridLines = GridLines.Both;
    grdreport1.Font.Name = "Verdana";
    grdreport1.Font.Size = FontUnit.XXSmall;
    // grdreport1.HeaderStyle.BackColor = Color.DimGray;
    // grdreport1.HeaderStyle.ForeColor = Color.White;
    grdreport1.RowStyle.HorizontalAlign = HorizontalAlign.Center;
    grdreport1.RowStyle.VerticalAlign = VerticalAlign.Top;
    grdreport1.RenderControl(htmlWrite);
    Response.Write(stringWrite.ToString());
    Response.End();
}
Posted
Updated 28-May-14 20:57pm
v2
Comments
soumyajayaraj 29-May-14 2:47am    
Which library are you using to export to excel? How are you storing the data? Are you storing the data in a datatable? Please provide more information in your question.
phmani469 29-May-14 2:58am    
im new to .net.....Im updated my code....If u have doubt ask 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