Friday, 31 August 2012

VB.NET - Excel - How to freeze panes

also check http://howtodomssqlcsharpexcelaccess.blogspot.ca/2012/08/vbnet-how-to-creae-excel-file-simple.html   

    Dim fileTest As String = "C:\Temp\ExcelTest\test.xlsx"
        If File.Exists(fileTest) Then
            File.Delete(fileTest)
        End If

        Dim oExcel As Object
        oExcel = CreateObject("Excel.Application")
        Dim oBook As Excel.Workbook
        Dim oSheet As Excel.Worksheet

        oBook = oExcel.Workbooks.Add
        oSheet = oExcel.Worksheets(1)

        oSheet.Name = "no name"
        oSheet.Range("A1").Value = "FirstName"
        oSheet.Range("B1").Value = "Year"
        oSheet.Range("C1").Value = "Salary"

        oSheet.Range("A2").Value = "Frank"
        oSheet.Range("B2").Value = "2012"
        oSheet.Range("C2").Value = "20000"

        oSheet.Range("A3").Value = "John"
        oSheet.Range("B3").Value = "2012"
        oSheet.Range("C3").Value = "30000"

        oSheet.Range("A4").Value = "Bob"
        oSheet.Range("B4").Value = "2012"
        oSheet.Range("C4").Value = "40000"

        oSheet.Range("A5").Value = "Elvis"
        oSheet.Range("B5").Value = "2012"
        oSheet.Range("C5").Value = "60000"

        oSheet.Range("A2", "A2").Select()
        oExcel.ActiveWindow.FreezePanes = True


        oBook.SaveAs(fileTest)
        oBook.Close()
        oBook = Nothing
        oExcel.Quit()
        oExcel = Nothing

Same example on YouTube

1 comment:

  1. How To Do - Ms Sql C Excel Access: Vb.Net - Excel - How To Ze Panes >>>>> Download Now

    >>>>> Download Full

    How To Do - Ms Sql C Excel Access: Vb.Net - Excel - How To Ze Panes >>>>> Download LINK

    >>>>> Download Now

    How To Do - Ms Sql C Excel Access: Vb.Net - Excel - How To Ze Panes >>>>> Download Full

    >>>>> Download LINK xM

    ReplyDelete