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. Problem in opening an excel file using C#

Problem in opening an excel file using C#

Scheduled Pinned Locked Moved C#
helpcsharpcom
2 Posts 2 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
    ramyanaidu
    wrote on last edited by
    #1

    OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = @":D\\"; ofd.Filter = "Excel Files(*.xls)|*.xls|" + "All Text Files(*.*)|*.*"; ofd.FilterIndex = 1; if (ofd.ShowDialog() == DialogResult.OK) { excelApp = new Excel.Application(); workBook = excelApp.Workbooks.Open(ofd.FileName, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true,1,0); When i run this code i get an error as "Unable to cast COM object of type 'Excel.ApplicationClass' to interface type 'Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID "" plz any one help me in this Regards Ramya

    N 1 Reply Last reply
    0
    • R ramyanaidu

      OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = @":D\\"; ofd.Filter = "Excel Files(*.xls)|*.xls|" + "All Text Files(*.*)|*.*"; ofd.FilterIndex = 1; if (ofd.ShowDialog() == DialogResult.OK) { excelApp = new Excel.Application(); workBook = excelApp.Workbooks.Open(ofd.FileName, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true,1,0); When i run this code i get an error as "Unable to cast COM object of type 'Excel.ApplicationClass' to interface type 'Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID "" plz any one help me in this Regards Ramya

      N Offline
      N Offline
      NewToAspDotNet
      wrote on last edited by
      #2

      use Excel.ApplicationClass() instead of Excel.Application() ..

      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