Export Data to Ms Excel 2000

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chia Lee Lee
    New Member
    • Oct 2006
    • 8

    Export Data to Ms Excel 2000

    Hi ,

    I have no idea on how to export data to Ms Excel 2000.
    I have a screen which contain a check box list that allow user to select which fields to be exported to MS Excel.
    When user checked on the check box, that field's data from database will be exported to Ms Excel.
    My program is client -based system.
    Programming language=VB.NET
    Software=MS Visual Studio.net2003
    Platform=Window XP Pro,SP1


    Thanks for all of yours helps......

    Carol
  • mady1380
    New Member
    • Sep 2006
    • 18

    #2
    Originally posted by Chia Lee Lee
    Hi ,

    I have no idea on how to export data to Ms Excel 2000.
    I have a screen which contain a check box list that allow user to select which fields to be exported to MS Excel.
    When user checked on the check box, that field's data from database will be exported to Ms Excel.
    My program is client -based system.
    Programming language=VB.NET
    Software=MS Visual Studio.net2003
    Platform=Window XP Pro,SP1


    Thanks for all of yours helps......

    Carol

    hi carol

    just try this you can insert records into excel with this code.

    *************** *************** ************

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
    'Put user code to initialize the page here

    'Create new Excel Object
    Dim MyExcel As Excel.Applicati on

    MyExcel = New Excel.Applicati on
    MyExcel.Display Alerts = False
    MyExcel.Workboo ks.Open("C:\Ine tpub\wwwroot\We bApplication1\E xcel1.xls")
    Label1.Text = MyExcel.ActiveW orkbook.ActiveS heet.Cells(1, 1).Value

    'Insert data into particular cell of Excel Sheet
    MyExcel.ActiveW orkbook.ActiveS heet.cells(2, 4) = "Example"

    MyExcel.ActiveW orkbook.Save()
    MyExcel.ActiveW orkbook.Close(F alse, "C:\Inetpub\www root\WebApplica tion1\Excel1.xl s")
    MyExcel.Display Alerts = False
    MyExcel.Quit()


    ReleaseComObjec t(MyExcel)
    MyExcel = Nothing
    GC.Collect(1)
    GC.WaitForPendi ngFinalizers()
    End Sub

    *************** *************** **

    but informing you that i have problem with this code is that..
    my Excel.EXE is still running in background even after i close my application.

    i am still trying on that..mean time if you get something how to kill it let me know
    thanks

    mady

    Comment

    • kenvil
      New Member
      • Nov 2006
      • 1

      #3
      that's a really big problem in using Excel Object. that was also my problem before
      the only solution i know that will work in disposing the excel object is the kill the process itself

      the code goes like these:

      Dim myProcesses As Process() = Process.GetProc essesByName("EX CEL")
      Dim myProcess As Process
      For Each myProcess In myProcesses
      myProcess.Kill( )
      Next myProcess

      Comment

      Working...