Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Opening .xls file in Excel from C#

Opening .xls file in Excel from C#

Scheduled Pinned Locked Moved C#
csharphelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eyalbi007
    wrote on last edited by
    #1

    Hi all, I'm trying to open an existing Excel file using Excel, from my C# application. I've managed doing so using the following code: Excel.Application excelApp = new Excel.Application(); Excel.Workbook workBook = excelApp.Workbooks.Open(strFileName, 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); excelApp.Visible = true; However, I'm facing the following problem: Opening the file using this code creates a new process - EXCEL.exe, which doesn't ends after closing the Excel application! What am I doing wrong? Thanks a lot, Eyal.

    G E J 3 Replies Last reply
    0
    • E eyalbi007

      Hi all, I'm trying to open an existing Excel file using Excel, from my C# application. I've managed doing so using the following code: Excel.Application excelApp = new Excel.Application(); Excel.Workbook workBook = excelApp.Workbooks.Open(strFileName, 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); excelApp.Visible = true; However, I'm facing the following problem: Opening the file using this code creates a new process - EXCEL.exe, which doesn't ends after closing the Excel application! What am I doing wrong? Thanks a lot, Eyal.

      G Offline
      G Offline
      Gareth H
      wrote on last edited by
      #2

      eyalbi007, Some of the links in google might have some interesting info that might help. http://www.google.co.uk/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&hs=pjC&q=Excel.Application+close&btnG=Search&meta=[^]

      Regards, Gareth. (FKA gareth111)

      1 Reply Last reply
      0
      • E eyalbi007

        Hi all, I'm trying to open an existing Excel file using Excel, from my C# application. I've managed doing so using the following code: Excel.Application excelApp = new Excel.Application(); Excel.Workbook workBook = excelApp.Workbooks.Open(strFileName, 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); excelApp.Visible = true; However, I'm facing the following problem: Opening the file using this code creates a new process - EXCEL.exe, which doesn't ends after closing the Excel application! What am I doing wrong? Thanks a lot, Eyal.

        E Offline
        E Offline
        Ed Poore
        wrote on last edited by
        #3

        If you just want to display the file then how about:

        System.Diagnostics.Process.Start(strFileName);

        That'll just launch the default viewer for the filename.

        I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder

        1 Reply Last reply
        0
        • E eyalbi007

          Hi all, I'm trying to open an existing Excel file using Excel, from my C# application. I've managed doing so using the following code: Excel.Application excelApp = new Excel.Application(); Excel.Workbook workBook = excelApp.Workbooks.Open(strFileName, 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); excelApp.Visible = true; However, I'm facing the following problem: Opening the file using this code creates a new process - EXCEL.exe, which doesn't ends after closing the Excel application! What am I doing wrong? Thanks a lot, Eyal.

          J Offline
          J Offline
          Jimmanuel
          wrote on last edited by
          #4

          have you made sure that you release all of your COM objects (like excelApp) when you're finished with them? Marshal.ReleaseComObject(...) : http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.releasecomobject(VS.80).aspx[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups