本文介绍了Asp.Net导出到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想在只读模式下导出excel。用户不应该编辑Excel工作表。请帮忙。导出工作但不是只读属性。



Hi ,

I want to export excel on read only mode.User should not edit the Excel sheet. Please help. Export is working but not Read only property.

Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click
       Response.Clear()
       Response.AddHeader("content-disposition", "attachment; filename=ABC.xls")
       Response.Charset = ""
       Response.ContentType = "application/vnd.xls"

       Dim FilePathName As String = Request.PhysicalPath
       Response.WriteFile(FilePathName, IO.FileMode.Open, IO.FileAccess.Read)
       Dim stringWrite As New System.IO.StringWriter()
       Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)

       GridView1.HeaderRow.Style.Add("background-color", "#99CCFF")
       GridView1.RenderControl(htmlWrite)
       Response.Write(stringWrite.ToString())

       Response.[End]()

推荐答案



这篇关于Asp.Net导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 23:47
查看更多