5

I am trying to migrate my existing WCF service to .Net5.0 Web API. Currently we have Excel Interop dependency to implement excel cells update, running macro inside excel & then capturing the screenshot of specific cell range.

When I am trying to add Microsoft Interop with .Net5.0 using nuget package, seeing warning like it is not compatible other than .Net Frameworks.

Can anyone help me is it possible to add nuget package to .Net5.0 Web API project?

Buddha
  • 185
  • 1
  • 15
  • 1
    Office interop is windows only feature, and it is bad way to work with excel sheets, especially server side. Consider using library that works with excel file structure directly, not making COM calls. Aspose.NET is very functional library, same as expensive. Syncfuion.XlsIO you can use for free with some restricitons. – Alexey Rumyantsev Feb 04 '21 at 05:27
  • 1
    Thanks for the response @AlexeyRumyantsev. But with this technology upgrade we cannot make that change. Why we are going with excel is a big story. We have more than 10K formulas within excel which are running with the macro triggered from service. We have the plan to change that excel to some other, but we need to use Excel Interop only – Buddha Feb 04 '21 at 07:45
  • Maybe you even don't need to move to .NET 5? Stay on .NET framework for a while, if you have to support such legacy things. You can start rearchitecting your solution, and still use and support old solution in parallel. – Alexey Rumyantsev Feb 04 '21 at 09:25

1 Answers1

4

As @Alexey Rumyantsev says, the Microsoft Interop wouldn't be possible to port to .Net core because it relies on the Office interops. The Office interops is windows ony feature. More details ,you could refer to this github issue.

If you still want to use Microsoft Interop Excel in asp.net core, I suggest you could try to create a new .NET Framework 4.X project. Add the relevant COM references to the project. Edit the .csproj of your .NET Core 5.0 project and add the generated references from the .NET Framework project to the tag.

Notice: We don't suggest you use this way, we suggest you use other EXCEL library.

More details, you could refer to this answer.

Brando Zhang
  • 22,586
  • 6
  • 37
  • 65