[RESOLVED]Grid to MS Word

Hi All,

 

I want to display my dataGridView to MS Word format, how to do this,post ur suggestions please

anigova

dataGridView

Is this a Windows Forms application?

Thanks for reply, its Web apllication

public override void VerifyRenderingInServerForm(Control control)
        {
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition","attachment;filename=GridViewtoWord.doc");
            Response.Charset = "";
            Response.ContentType = "application/vnd.ms-word";
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            dataGridView.DataBind();
            dataGridView.AutoGenerateColumns = false;
            dataGridView.RenderControl(hw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();

         }

got it……………………..

Leave a Reply