1
Answer

After exporting data from gridview to excel i want to make this excel as read-only

Sweety

Sweety

13y
2.7k
1
In my application im exporting gridview data to excel and now what i want is to make this excel as read only so that no one can edit it if they try it should dispplay error message like you are not allowed to modified like that

i got code for exporting gridview data to excel in net

public void ExportGridToExcel(GridView grdGridView, string fileName)

{


Response.Clear();

Response.ContentType = "application/vnd.xls";

StringWriterstringWrite = new StringWriter();


HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

GridView1.RenderControl(htmlWrite);

Response.Write(stringWrite.ToString());


Response.End();


}

public override void VerifyRenderingInServerForm(Control control)
{

}


now how can i make this file as readonly..

can any 1 help me on this..



/* Verifies that a Form control was rendered */

Response.AddHeader("content-disposition",string.Format("attachment;filename={0}.xls", fileName));
Response.Charset = "";

Answers (1)