Grid To Excel
-
In my application i had headings in between the grid rows when i export the grid to excel the headings were not displayed i used the code like this Response.Clear(); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite); htmlWrite.WriteLine("<b><font size=5 color=red>" + Heading.ToString() + "</font></b> <b><font size=4 color=blue>TDP IT-Department</font></b>"); //System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid(); //dg.DataSource = dv.Table; //dg.DataBind(); gv.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); help me out to solve this
-
In my application i had headings in between the grid rows when i export the grid to excel the headings were not displayed i used the code like this Response.Clear(); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite); htmlWrite.WriteLine("<b><font size=5 color=red>" + Heading.ToString() + "</font></b> <b><font size=4 color=blue>TDP IT-Department</font></b>"); //System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid(); //dg.DataSource = dv.Table; //dg.DataBind(); gv.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); help me out to solve this
Not shown at all, or just not styled ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Not shown at all, or just not styled ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
not shown at all an empty row is being displayed i used the code like this to add a row to grid DataTable dt1 = dv1.ToTable(true, "nDepartmentID", "sDepartmentName"); int i = 2; // Session["i"] = ds.Tables[0].DefaultView; for (int m = 0; m <= dt1.Rows.Count - 1; m++)// foreach (DataRow dr in dt1.Rows) { DataTable dt = dv1.ToTable("dt", false); object objCount = dt.Compute("count(nDepartmentID)", "nDepartmentID in (" + int.Parse(dt1.Rows[m]["nDepartmentID"].ToString()) + ")"); if (dt.Rows.Count > 0) { GridViewRow gvRow = new GridViewRow(i, 0, DataControlRowType.DataRow, DataControlRowState.Insert); TableCell tblCell = new TableCell(); //Add Summary Row tblCell.Text = dt1.Rows[m]["sDepartmentName"].ToString(); tblCell.ColumnSpan = 6; tblCell.BorderWidth = 2; tblCell.HorizontalAlign = HorizontalAlign.Left; tblCell.ForeColor = System.Drawing.Color.Red; tblCell.Font.Bold = true; tblCell.Font.Size = 12; gvRow.Cells.Add(tblCell); gridView.Controls[0].Controls.AddAt(i, gvRow); i = i + int.Parse(objCount.ToString()) + 1; } }
-
In my application i had headings in between the grid rows when i export the grid to excel the headings were not displayed i used the code like this Response.Clear(); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite); htmlWrite.WriteLine("<b><font size=5 color=red>" + Heading.ToString() + "</font></b> <b><font size=4 color=blue>TDP IT-Department</font></b>"); //System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid(); //dg.DataSource = dv.Table; //dg.DataBind(); gv.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); help me out to solve this
use this code. Dim attachment As String = "attachment; filename=MyFile.xls" Response.ClearContent() Response.AddHeader("content-disposition", attachment) Response.ContentType = "application/ms-excel" Dim sw As New StringWriter() Dim htw As New HtmlTextWriter(sw) Dim frm As New HtmlForm() GridViewEmployeeRegistrationDetails.Parent.Controls.Add(frm) frm.Attributes("runat") = "server" frm.Controls.Add(GridViewEmployeeRegistrationDetails) frm.RenderControl(htw) Response.Write(sw.ToString()) Response.End()
Thanks and Regards Sujit Kr. Mandal