Search code examples
c#excelsolution

Accessing an excel Project from A Winform Project in same Solution


I am trying to open an excel project in my Solution from a Winform Application. Please note:

  1. Winform is my starting Project.
  2. I can add Winform Reference in Excel but I can not add Excel Reference in Winform Project.

Screenshot of both projects in same solution

As I mentioned I cant find Excel Project in ADD REFERENCE>SOLUTION of Winform project. I also cant add it manually (Invalid dll or COM file Error!). Any idea?


Solution

  • To open up excel you can use this:

    Process.Start("excel.exe"); // or the real path of excel
    

    And to have it open up with a certain worksheet, you could pass as an argument the path of the file:

    Process.Start("excel.exe \"c:\My Folder\book1.xlsx\"");