nissl-lab / npoi

a .NET library that can read/write Office formats without Microsoft Office installed. No COM+, no interop.
Apache License 2.0
5.75k stars 1.43k forks source link

System.Runtime.CompilerServices.Unsafe 4.0.41 not found while calling AsSpan #1320

Closed softboy99 closed 7 months ago

softboy99 commented 7 months ago

NPOI Version Used

2.7.0

File Type

Use Case

update dependency System.Runtime.CompilerServices.Unsafe.dll to 6.0

Description

Bykiev commented 7 months ago

Hi, can you please explain in details the issue. NPOI hasn't direct dependency on this library https://www.nuget.org/packages/NPOI/#dependencies-body-tab

softboy99 commented 7 months ago

Hi, it's enum.net issue,i have post it to its github site. but now i have another issue, how to open an password protected excel for reading? Is it possible for the 2.7 version?

code:

fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); WorkbookFactory.Create(fs, true);

exception: “RemoveDataValidation” has not been implemented

Bykiev commented 7 months ago

Password protection is only available for xlsx files:

IWorkbook workbook = WorkbookFactory.Create("encryped.xlsx", "password");

softboy99 commented 7 months ago

don't know password

softboy99 commented 7 months ago

in addition, the enums.net lib author seems doesn't maintian any more :

https://github.com/TylerBrinkley/Enums.NET/issues/42

Bykiev commented 7 months ago

don't know password

I you don't know the password, you can't open such file.

tonyqus commented 7 months ago

don't know password

This is illegal. We don't provide this kind of feature.

tonyqus commented 7 months ago

@softboy99 I checked Enums.NET nuget just now. The last version is just released 3 month ago. Why do you say it's not maintained anymore? Any clues?

tonyqus commented 7 months ago

Only one question in one issue. If you have other question, please open a new issue. Thanks

softboy99 commented 7 months ago

在 System.MemoryExtensions.AsSpan(String text) 在 NPOI.SS.Util.CellReference..ctor(String cellRef) 在 C:\Users\ander\Downloads\npoi-master\main\SS\Util\CellReference.cs 中: 第 84 行 在 NPOI.XSSF.UserModel.XSSFCell..ctor(XSSFRow row, CT_Cell cell) 在 C:\Users\ander\Downloads\npoi-master\ooxml\XSSF\UserModel\XSSFCell.cs 中: 第 93 行 在 NPOI.XSSF.UserModel.XSSFRow..ctor(CT_Row row, XSSFSheet sheet) 在 C:\Users\ander\Downloads\npoi-master\ooxml\XSSF\UserModel\XSSFRow.cs 中: 第 285 行 在 NPOI.XSSF.UserModel.XSSFSheet.InitRows(CT_Worksheet worksheetParam) 在 C:\Users\ander\Downloads\npoi-master\ooxml\XSSF\UserModel\XSSFSheet.cs 中: 第 4054 行 在 NPOI.XSSF.UserModel.XSSFSheet.Read(Stream is1) 在 C:\Users\ander\Downloads\npoi-master\ooxml\XSSF\UserModel\XSSFSheet.cs 中: 第 1221 行 在 NPOI.XSSF.UserModel.XSSFSheet.OnDocumentRead() 在 C:\Users\ander\Downloads\npoi-master\ooxml\XSSF\UserModel\XSSFSheet.cs 中: 第 1201 行

softboy99 commented 7 months ago

image

tonyqus commented 7 months ago

Can you create a single console project and reproduce the issue? I'm afraid the issue you are encountering is somewhat related to your package reference in your project.

According to the call stack, this issue is caused by AsSpan method. It's nothing to do with Enums.NET.

Bykiev commented 7 months ago

@softboy99, check the binding redirects for System.Runtime.CompilerServices.Unsafe

leafcxy commented 1 day ago

NPOI Version Used

2.7.0

File Type

  • [ ] XLSX
  • [ ] XLS

Use Case

update dependency System.Runtime.CompilerServices.Unsafe.dll to 6.0

Description

Normal after updating the version of Npoi version=2.7.2