Asp.Net导出到Excel [英] Asp.Net Export to Excel
本文介绍了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]()
推荐答案
同类的问题回答
如何插入导出为excel并将readonly设置为这些单元格时的公式 [ ^ ]
Similar question with answer
How to insert formula while exporting to excel and set readonly to those cells[^]
访问这里...
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/ExportASPNetDataGridToExcel11222005041447AM/ExportASPNetDataGridToExcel .aspx [ ^ ]
或
http://www.codedigest.com/Articles/ASPNET/130_Export_to_Excel_in_ASPNet_20_%E2%80%93Gridview_to_Excel_DataTable_to_Excel.aspx [ ^ ]
visit here...
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/ExportASPNetDataGridToExcel11222005041447AM/ExportASPNetDataGridToExcel.aspx[^]
or
http://www.codedigest.com/Articles/ASPNET/130_Export_to_Excel_in_ASPNet_20_%E2%80%93Gridview_to_Excel_DataTable_to_Excel.aspx[^]
这篇关于Asp.Net导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文