Hi,
I am exporting asp.net grid data to excel. But I am not sure about setting password for that, Can anyone give an idea about this ., here is my code..
Protected Sub btnPayroll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPayroll.Click
Response.Clear()
Response.AddHeader("content-disposition", "attachment; filename=Monthly Payroll.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
Dim FilePathName As String = Request.PhysicalPath
Dim fileInfo = New IO.FileInfo(FilePathName)
fileInfo.IsReadOnly = True
GridView1.HeaderRow.Style.Add("background-color", "#99CCFF")
GridView1.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.[End]()
End Sub