CS0234: The type or namespace name ‘Office’ does not exist in the namespace ‘Microsoft’

CS0234: The type or namespace name ‘Office’ does not exist in the namespace ‘Microsoft’

The issue in Visual Studio by executing the following code using the following lines:

using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;

Solution: Need to install Microsoft.Office.Interop.Excel package.

  1. Go to the Reference button in the Right side window of solution explorer:

2. Right-click on the References button and select the NuGet Packages as shown below:

3. It will open the new window, you will click on Browse Button and go to Search: type “EXCEL” and go for search as shown below:

4. Install Microsoft.Office.Interop.Exec by selecting it for download as below screen appears:

5. After download, it will remove the errors on build it again.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.