Click here to Skip to main content
15,178,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I need to export gridview to excel .I am using the following code for the same
C#
Response.ClearContent();
 
Response.AddHeader(
 

"content-disposition", "attachment; filename=MyExcelFile.xls"); 
 
Response.ContentType =
 

"application/excel";
 

 

StringWriter sw = new StringWriter();
 

 

HtmlTextWriter htw = new HtmlTextWriter(sw);
 
Gridview1.RenderControl(htw);
 
Response.Write(sw.ToString());
 
Response.End();




It gets exported from the grid view to the excel.but the excel needs to be protected sheet with the password generated and hide one column from the code.This is for payroll..

Thanks..
Posted
Updated 22-Aug-14 21:56pm
v2

Have a look at the below link may be it helps
Implementing Password Security on Excel Workbooks Using Visual Studio .NET[^]
   
Comments
sankmahesh 23-Aug-14 2:29am
   
i try that but not working
   
Comments
sankmahesh 23-Aug-14 8:58am
   
i need hide column in gridview to excel with hide. the above code the gridview hidden column is not coming to excel.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900