我正在使用 Gembox 打开、修改和保存 xlsx 文件。对 Excelfile 调用 Save 会导致 System.IO.FileNotFoundException。
问题发生在我们公司的序列号和免费密钥上。
示例代码
using GemBox.Spreadsheet;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
var path = @"C:\code\GemboxTest\App.xlsx";
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
ExcelFile ef = ExcelFile.Load(path);
ExcelWorksheet ws = ef.Worksheets[0];
//ws.Columns[0].Cells[0].Value = 42;
ef.Save(path); // <--------------------------------- Crash!
}
}
}
错误信息
Could not load file or assembly 'System.Security.Permissions, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
System.Security.Permissions, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
堆栈跟踪
at .(Stream , Byte[] , Int32 , Int32 , String )
at .(Stream )
at .(Stream )
at . ()
at .(Stream )
at .Dispose()
at . (Boolean )
at .Dispose()
at . ()
at .(Boolean )
at .Dispose()
at GemBox.Spreadsheet.XlsxSaveOptions.(ExcelFile , Stream , )
at GemBox.Spreadsheet.XlsxSaveOptions.Save(ExcelFile excelFile, Stream stream, String path)
at GemBox.Spreadsheet.SaveOptions.(ExcelFile , String )
at GemBox.Spreadsheet.ExcelFile.Save(String path, SaveOptions options)
at GemBox.Spreadsheet.ExcelFile.Save(String path)
at ConsoleApp.Program.Main(String[] args) in C:\code\GemboxTest\ConsoleApp\Program.cs:line 14
版本
- .NET Core 3.1(3.0 也失败)
- GemBox.Spreadsheet 版本=45.0.1131
- Visual Studio 2019 (VisualStudioVersion = 16.0.29905.134)
- Windows 10 专业版 64 位
示例 csproj 文件
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GemBox.Spreadsheet" Version="45.0.1131" />
</ItemGroup>
</Project>