title: ASP.NET Export to Excel - Lock Cells
body: <p>I'd like to export a table I have on my webpage to an Excel file and <strong>lock some cells in the new file</strong>.  Here is my current code:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>This code works in generating the Excel file. I've searched for an was unable to find much for a solution to lock cells in the new file.  Thanks in advance for the help!</p>