从Gridview Asp.net导出后设置Excel的密码 [英] Set password for Excel after exporting from Gridview Asp.net

查看:73
本文介绍了从Gridview Asp.net导出后设置Excel的密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我将asp.net网格数据导出到excel。但我不确定是否设置了密码,任何人都可以对此有所了解。这是我的代码..



受保护的子btnPayroll_Click(ByVal sender As Object ,ByVal e As System.EventArgs)处理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 =新IO.FileInfo(FilePathName)

fileInfo.IsReadOnly = True



GridView1.HeaderRow.Style.Add(background-color,#99CCFF)





GridView1.RenderCon trol(htmlWrite)

Response.Write(stringWrite.ToString())

响应。[结束]()

结束Sub

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

推荐答案

嗨会员,请参阅此链接 [ ^ ]



这个 [ ^ ]



如果以上解决方案对您没有帮助,请在此处发布您的查询。



谢谢

Ganesh
Hi member, see this link[^]

and this [^]

if the above solutions does not helps you, please post your query here.

Thanks
Ganesh


这篇关于从Gridview Asp.net导出后设置Excel的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆