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. Datagridview to Excel.....using error (again)

Datagridview to Excel.....using error (again)

Scheduled Pinned Locked Moved C#
csharpcomhelpasp-netvisual-studio
3 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.
  • P Offline
    P Offline
    PDTUM
    wrote on last edited by
    #1

    Good Morning, The reason I have prefaced this with "again" is that although I have found numerous articles on this in Code Project, I have yet to see this problem resolved with a clear answer or a suggestion as to what the problem might be (or I cannot find it). So, it's my turn in the barrel...I am trying to add an Excel reference (seems simple enough) to my application (VS 2010), and I have tried to add it from both the .NET (Microsoft.Office.Excel) and COM tabs (Microsoft.Office.Interop.Excel) under Add Reference. I have also added the Microsoft.Office.Core Excel Object (12.0). I have tried each individually and all simultaneously and each time I get the familiar error (Error 1 The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?). This was done as per the instructions of a great article on Code Project by Geek13 that begins with the code Excel.ApplicationClass ExcelApp = new Excel.ApplicationClass(); The article heading is as follows: Exporting a DataGridView to Excel in .NET 2.0 (C# code) Author: Geek13 If there is some other prerequisite that I need or (???), please let me know. Thank you for your attention....Pat

    S 1 Reply Last reply
    0
    • P PDTUM

      Good Morning, The reason I have prefaced this with "again" is that although I have found numerous articles on this in Code Project, I have yet to see this problem resolved with a clear answer or a suggestion as to what the problem might be (or I cannot find it). So, it's my turn in the barrel...I am trying to add an Excel reference (seems simple enough) to my application (VS 2010), and I have tried to add it from both the .NET (Microsoft.Office.Excel) and COM tabs (Microsoft.Office.Interop.Excel) under Add Reference. I have also added the Microsoft.Office.Core Excel Object (12.0). I have tried each individually and all simultaneously and each time I get the familiar error (Error 1 The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?). This was done as per the instructions of a great article on Code Project by Geek13 that begins with the code Excel.ApplicationClass ExcelApp = new Excel.ApplicationClass(); The article heading is as follows: Exporting a DataGridView to Excel in .NET 2.0 (C# code) Author: Geek13 If there is some other prerequisite that I need or (???), please let me know. Thank you for your attention....Pat

      S Offline
      S Offline
      SledgeHammer01
      wrote on last edited by
      #2

      You should always add from the .NET tab. Also, you probably need to add a using Microsoft.Office.Core or something of that sort to bring the Excel namespace into scope.

      P 1 Reply Last reply
      0
      • S SledgeHammer01

        You should always add from the .NET tab. Also, you probably need to add a using Microsoft.Office.Core or something of that sort to bring the Excel namespace into scope.

        P Offline
        P Offline
        PDTUM
        wrote on last edited by
        #3

        Hammer, Thank you for your reply. FYI...I did delete all COM references to Excel and I had already added the MSFT Core, but it still did not work. Apparently, there was a problem with different versions that were added for each reference to Interop (V11.0 vs v14.0), and this was due to the fact that the article was based on VS2.0. So I needed to change the references, make them the same, and then find the new path to the application (old was ApplicationClass and new was just .Application). However, the problem was definitely found in the area that you suggested I look. Thanks for the help....much appreciation. I have marked your answer as correct. Best Regards, Pat

        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