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. clsoe issues excel sheet in C#

clsoe issues excel sheet in C#

Scheduled Pinned Locked Moved C#
comcsharphelpquestion
2 Posts 1 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.
  • R Offline
    R Offline
    Ravenet
    wrote on last edited by
    #1

    Hi Experts I'm facing issues when i try close the excel file,it's asking me do need save the changes dialog and also still running the excel exe in task manger how i can close th file with put nay dialog and properly cleanup. This my file op opening code Microsoft.Office.Interop.Excel.Workbook workbooks = bodynitsApplicationClass.Workbooks.Open(filename, 0, true, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); Microsoft.Office.Interop.Excel.Sheets sheets = workbooks.Worksheets; Close Method code: Marshal.ReleaseComObject(worksheetdetail); worksheetdetail = null; bodynitsApplicationClass.Quit(); while (Marshal.ReleaseComObject(bodynitsApplicationClass) != 0) { } bodynitsApplicationClass = null; GC.Collect(); GC.WaitForPendingFinalizers(); Missing anything ?, Please help me

    Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

    R 1 Reply Last reply
    0
    • R Ravenet

      Hi Experts I'm facing issues when i try close the excel file,it's asking me do need save the changes dialog and also still running the excel exe in task manger how i can close th file with put nay dialog and properly cleanup. This my file op opening code Microsoft.Office.Interop.Excel.Workbook workbooks = bodynitsApplicationClass.Workbooks.Open(filename, 0, true, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); Microsoft.Office.Interop.Excel.Sheets sheets = workbooks.Worksheets; Close Method code: Marshal.ReleaseComObject(worksheetdetail); worksheetdetail = null; bodynitsApplicationClass.Quit(); while (Marshal.ReleaseComObject(bodynitsApplicationClass) != 0) { } bodynitsApplicationClass = null; GC.Collect(); GC.WaitForPendingFinalizers(); Missing anything ?, Please help me

      Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

      R Offline
      R Offline
      Ravenet
      wrote on last edited by
      #2

      Thank you much , i found and corrected. Here for you. When you call the CloseMethod(your own method) private void close() { if (bodynitsApplicationClass != null) { bodynitsApplicationClass.DisplayAlerts = false; bodynitsApplicationClass.Workbooks.Close(); Marshal.ReleaseComObject(worksheetdetail); worksheetdetail = null; bodynitsApplicationClass.Quit(); Marshal.ReleaseComObject(bodynitsApplicationClass); bodynitsApplicationClass = null; } } everything dispose and close without dialog. thank you once again.

      Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

      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