Programmatically open Excel file in .NET 6

Urs Wagner 26 Reputation points
2022-09-29T13:50:07.22+00:00

Hello

I am using .NET 6 and I want to open the Excel file with Microsoft.Office.Interop.Excel.

Calling the constructor of my C# class I get this error:

System.IO.FileNotFoundException: 'Could not load file or assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. The system cannot find the file specified.'

I have installed Microsoft.Interop.Excel Nuget package.

I have installed in Visual Studio the office tools.

I am using the same code with .NET Framework 4.8. It is working fine.

Must a use another library?

Microsoft 365 and Office | Excel | For business | Windows
{count} votes

Answer accepted by question author
  1. Sina Salam 26,661 Reputation points Volunteer Moderator
    2022-10-04T11:45:13.48+00:00

    Hi @Urs Wagner

    Here is the repo link:

    https://github.com/sasinaola/WpfAppExcel.git

    Success.
    Sina


5 additional answers

Sort by: Most helpful
  1. Sina Salam 26,661 Reputation points Volunteer Moderator
    2022-10-04T10:27:22.403+00:00

    Hi @Urs Wagner

    I will suggest you to add those COM Manually.

    However, this platform does not accept zip file as an attachment. I will create a repo on GITHub and send you the public link.

    Cheers,
    Sina


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.