private void ExportGridView() { //To make the last row unbold// //int j = gvScoreList.Rows[0].Cells.Count; int i = gvMark.Rows.Count; //foreach (GridViewRow row in gvSalaryStatement.Rows) //{ //gvFeeReport.Rows[i - 1].Cells[j - 2].Text = "Total"; //} if (i > 0) { btnExportToWord.Visible = true; btnExportToExcel.Visible = true; string attachment = "attachment; filename=File.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); //gvScoreList.RenderControl(htw); //lblFailed.RenderControl(htw); pnlExport.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); } else { btnExportToWord.Visible = false; btnExportToExcel.Visible = false; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)