macos/.NET-如何创建NETv4应用程序
我正在尝试使用Microsoft.Office.Interop.Excel打开.xlsx,但在创建项目时,Visual Studio不允许我选择要使用的网络版本。 它使用v2,Microsoft.Office.Interop.Excel使用v4.6.1 我已经下载并安装了NetCore,但没有任何变化macos/.NET-如何创建NETv4应用程序,.net,.net,我正在尝试使用Microsoft.Office.Interop.Excel打开.xlsx,但在创建项目时,Visual Studio不允许我选择要使用的网络版本。 它使用v2,Microsoft.Office.Interop.Excel使用v4.6.1 我已经下载并安装了NetCore,但没有任何变化 using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; u
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using System.Data;
using Excel = Microsoft.Office.Interop.Excel;
namespace Prueba.Controllers{
[Route("/api/[controller]")]
public class OtroController : Controller{
[HttpGet]
public void SS(){
var ExcelApp = new Excel.Application();
ExcelApp.Workbooks.Open("/Applications/protected.xls",ReadOnly: true, Password: "1234");
}
}
}
产出:
An unhandled exception occurred while processing the request.
TypeLoadException: Could not load type 'Microsoft.Office.Interop.Excel._Application' from assembly 'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.
NuGet输出:
Package 'Microsoft.Office.Interop.Excel 15.0.4795.1000' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Interop
库只能在Windows上工作,就像在COM上一样。macOS没有COM
请注意:
- .NET Framework不在Mac上运行
- .NET核心!=。NET框架
- 您可以使用OpenXMLSDK修改Office文档文件
- .NET Framework不在Mac上运行
- .NET核心!=。NET框架
- 您可以使用OpenXMLSDK修改Office文档文件