我想將我在網頁上的表格導出到Excel文件,並且鎖定新文件中的某些單元格。以下是我目前的代碼:ASP.NET導出到Excel - 鎖定單元格
Protected Sub btnExportToExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExportToExcel.Click
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment;filename=EpicSearchResults.xls")
Response.Charset = ""
Me.EnableViewState = False
Dim sw As New System.IO.StringWriter()
Dim htw As New System.Web.UI.HtmlTextWriter(sw)
Session("tblResults").RenderControl(htw)
Response.Write(sw.ToString())
Response.End()
End Sub
此代碼可用於生成Excel文件。我搜索了一個無法找到解決方案鎖定新文件中的單元格。先謝謝您的幫助!
感謝您的建議。我會看一看。 – zeroef 2011-05-05 19:21:37