Here i will explain How to Export Gridview Data To Word. While Exporting I will explain the problems how to solve them. First download the ItextSharp from the above link.
Previously Explained
And Now i will Explain As the Title Says
protected void btnExpToWord_Click(object sender, EventArgs e)
{
try
{
ExpGvToExcelControl.AllowPaging = false;
BindGrid();
Response.ClearContent();
Response.AddHeader("content-disposition",
string.Format("attachment; filename={0}", "EmpInfo.doc"));
Response.Charset = "";
Response.ContentType = "application/ms-word";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
ExpGvToExcelControl.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
catch (Exception ex)
{
string ErrMsg = ex.Message;
}
}
Previously Explained
And Now i will Explain As the Title Says
protected void btnExpToWord_Click(object sender, EventArgs e)
{
try
{
ExpGvToExcelControl.AllowPaging = false;
BindGrid();
Response.ClearContent();
Response.AddHeader("content-disposition",
string.Format("attachment; filename={0}", "EmpInfo.doc"));
Response.Charset = "";
Response.ContentType = "application/ms-word";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
ExpGvToExcelControl.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
catch (Exception ex)
{
string ErrMsg = ex.Message;
}
}
No comments:
Post a Comment