Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am Using Fllowing method and Export Word File.I want to Add a  AddHeader and Detlais top Of the Word file.how to do it??
 
  protected void Button1_Click(object sender, EventArgs e)  
    {  
        ExportGridToword();  
    }  
    private void ExportGridToword()  
    {  
        Response.Clear();  
        Response.Buffer = true;  
        Response.ClearContent();  
        Response.ClearHeaders();  
        Response.Charset = "";  
        string FileName = "Vithal" + DateTime.Now +".doc";  
        StringWriter strwritter = new StringWriter();  
        HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter);        
        Response.Cache.SetCacheability(HttpCacheability.NoCache);  
        Response.ContentType ="application/msword";  
        Response.AddHeader("Content-Disposition","attachment;filename=" + FileName);  
        GridView1.GridLines = GridLines.Both;  
        GridView1.HeaderStyle.Font.Bold = true;  
        GridView1.RenderControl(htmltextwrtter);  
        Response.Write(strwritter.ToString());  
        Response.End();      
  
    }
Posted

1 solution

You need to use the proper APIs to have that level of control over documents, I think.

What on earth does this have to do with SQL Server ?
 
Share this answer
 

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