Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to display total in grid view, while exporting to excel?

$
0
0

Hi All,

How to display total in grid view, while exporting to excel? In my page, i have added one visual web part, In that web part there is two text boxes are there. I need to export those "text boxes" data. (i need to export "billable" and "non billable text boxes" data in excel.)

Below is my export to excel code. 

protected void btnExportToExcel_Click(object sender, EventArgs e)        {            txtBillable.Text = lblBillableTotal;                      gvHours.AllowPaging = false;            gvHours.AllowSorting = false;            gvHours.DataSource = Cache["dataset"];            gvHours.DataBind();            ChangeControlsToValue(gvHours);            Response.ClearContent();            string from = dtFrom.SelectedDate.ToShortDateString();            string to = dtTo.SelectedDate.ToShortDateString();            Response.AddHeader("content-disposition", "attachment; filename=" + from + "_to_" + to + ".xls");            Response.ContentType = "application/excel";            StringWriter sWriter = new StringWriter();            HtmlTextWriter hTextWriter = new HtmlTextWriter(sWriter);            HtmlForm hForm = new HtmlForm();            gvHours.Parent.Controls.Add(hForm);            hForm.Attributes["runat"] = "server";            hForm.Controls.Add(gvHours);            hForm.RenderControl(hTextWriter);            Response.Write(sWriter.ToString());            gvHours.AllowPaging = true;            gvHours.AllowSorting = true;            gvHours.DataSource = Cache["dataset"];            gvHours.DataBind();            Response.End();        }

Thanks and Regards,

Murali.K


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>