string sql1 = "SELECT Package FROM Package WHERE ID='1'"; SqlConnection con1 = new SqlConnection(cls.GetConnectionString()); SqlCommand cmd1 = new SqlCommand(sql1, con); SqlDataAdapter da1 = new SqlDataAdapter(cmd1); DataTable dt1 = new DataTable(); da1.Fill(dt1); dt1.Columns.Add("Description"); foreach (DataRow dr1 in dt1.Rows) { if (dr1 != null) { byte[] byt1 = (byte[])dr1[0]; string str1; System.Text.ASCIIEncoding enc1 = new System.Text.ASCIIEncoding(); str1 = enc1.GetString(byt1); dr1[1] = str1; description = str1; } }
public void CreateWordFile(DataTable dt) { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=Publish.doc"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-word "; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); GridView gvTemp = new GridView(); gvTemp.AllowPaging = false; gvTemp.DataSource = dt; gvTemp.DataBind(); gvTemp.RenderControl(hw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); }
<p style="margin: 0px; text-align: center;">Header</p> <p style="margin: 0px; text-align: center;">Color <span style="color: #ff0000;">Red</span></p><br /> <p style="margin: 0px; text-align: center;">Heading</p> <table width="100%" cellspacing="1" border="0" id="table1"> <tbody> <tr> <td> <p align="center">TITLE</p></td> <td width="9"> </td></tr> <tr> <td width="11"> </td> <td> </td> <td width="9"> </td></tr> <tr> <td width="11"> </td> <td> <p align="justify"><b>Description</b><br /> Details &.</p></td> <td width="9"> </td></tr> <tr> <td width="11"> </td> <td> </td> <td width="9"> </td></tr> <tr> <td width="11"> </td> </tr></tbody></table> ><span style="font-weight: bold;">Color</span></p><span style="font-weight: bold;"> Footer</span>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)