I am using ExcelLibrary dll .
I want to Freeze the Header Row .. Can any body suggest how I might do this?
I have tried the following code..
Imports System.Data.SqlClient
Imports ExcelLibrary
Imports ExcelLibrary.SpreadSheet
Partial Class DownloadExcel
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Try
Dim wb As New Workbook()
Dim sheetrowcounter As Integer
sheetrowcounter = 0
Dim sheet As New ExcelLibrary.SpreadSheet.Worksheet("ExcelSheet")
sheet.Cells(sheetrowcounter, 0) = New Cell("DELIVERY MONITORING SUMMARY(PROJECT GRANDE) ")
sheet.Cells(sheetrowcounter, 2) = New Cell("")
sheet.Cells(sheetrowcounter, 3) = New Cell("Report Date: '" & DateTime.Now.ToString("yyyy/MM/dd H:mm:ss tt") & " ")
sheetrowcounter += 1
sheetrowcounter += 1
sheet.Cells(sheetrowcounter, 0) = New Cell("Sl No")
sheet.Cells.ColumnWidth(0) = 10000
sheet.Cells(sheetrowcounter, 1) = New Cell("Name")
sheet.Cells.ColumnWidth(1) = 6000
sheetrowcounter += 1
Dim t As DataTable = Session("exceltable")
For i As Integer = 1 To t.Rows.Count - 1
Try
sheet.Cells(sheetrowcounter, 0) = New Cell(t.DefaultView.Item(i)(0))
sheet.Cells(sheetrowcounter, 1) = New Cell(t.DefaultView.Item(i)(1))
sheetrowcounter += 1
Catch ex As Exception
End Try
Next
sheet.Cells(0, 0).Format.FormatString = "freeze"
wb.Worksheets.Add(sheet)
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment;filename=DeliveryMonitoringSummaryDaily.xls")
Dim m As System.IO.MemoryStream = New System.IO.MemoryStream()
wb.SaveToStream(m)
m.WriteTo(Response.OutputStream)
Catch ex As Exception
End Try
End Sub
End Class
I am Storing a Datatable with 2 columns and some Rows in the Session("exceltable") object..
I don't have experience working with Excel Library you specified but I can to suggest to migrate to EPPlus library which is free and available on the http://epplus.codeplex.com/ site. This is very easy to use library with clear API and was designed to create advanced Excel 2007/2010 spreadsheets on the server. We used it successfully on several production projects. Using it you can achieve what you need by using ExcelSheet.View.FreezePanes method. I understand that my answer not answer your question, but it can be treated as alternative solution to you problem (I really don't know if you can or not to achieve what you need with Excel Library you specified).