-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SetCellValue with DateOnly does not work on .NET 7 project #1118
Comments
What do you mean this is failing? What kind of exception do you receive? |
Sorry, I explained badly... the SetCellValue(DateOnly....) does not exist in the interface for version 2.6.1. |
@lahma Sorry, it's my fault. I manually released 2.6.1 as what I did before. I don't know your GithubAction setup can do it automatically. The main purpose of getting rid of 6.0 and 4.7.2 version is to reduce the size of the nuget package. I suppose .NET Standard 2.1 can be fully compatible with .NET 6. And all .NET 6.0 feature are usable (such as DateOnly) I'm thinking releasing a new version. I'm still evaluating the impact of mis-release of NPOI 2.6.1. But it looks not many developers are really using DateOnly feature. |
Currently the package is created for each build and follows the version number in
This might not be such an issue. Downloaded package resides in global NuGet packages directory and only target frameworks DLLs are pulled into user's solution build and release artifacts.
👍🏻 |
Doing this code:
cell.SetCellValue(DateOnly.FromDateTime(dateTimeValue));
was working on NPOI 2.6.0, in NPOI 2.6.1 this is failing.
Looking at the source code for Cell.cs interface you have the conditional symbol NET6_0_OR_GREATER but this is not being defined so we get a compilation error.
In this issue (dotnet/sdk#22625) is mentioned that the NET6_0_OR_GREATER symbol is only there if the project is targeting .net 6 or greater.
I'm using NPOI in a class library that targets .NET7 so I don't understand why this could be an issue. In the nuget package manager in visual studio it only shows the dependencies for .netstandard 2.0 and .netstandard 2.1. If I choose version 2.6.0 it shows the dependencies for .netstandard 2.0, .netstandard 2.1, .netframework 4.7.2 and net6.0 thus defining the NET6_0_OR_GREATER symbol (see images below)
Version 2.6.0
Version 2.6.1
Could this be related to the way you deployed the packaged in nuget?
If anybody wants a workaround while this is not fixed you can use the code it does internally:
cell.SetCellValue(DateUtil.GetExcelDate(dateTimeValue, workbook.IsDate1904()));
The text was updated successfully, but these errors were encountered: