I have generated a Excel report using C#,which generated fine.now i need to do all of those field is to be noneditable.how could i do it
Here my Export to Excel COde below:
#region Export to Excel
if (dt.Rows.Count > 0)
{
string filename = reportName + ".xls";
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
GridView dgGrid = new GridView();
dgGrid.DataSource = dt;
dgGrid.DataBind();
for (int i = 0; i < dgGrid.Rows.Count; i++)
{
dgGrid.Rows[i].Cells[4].Attributes.Add("style", "mso-number-format:\\@");
}
//Get the HTML for the control.
dgGrid.RenderControl(hw);
//Write the HTML back to the browser.
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.End();
}
#endregion
please let me know as early as possible.
thanks in advance