-
-
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
Add DateOnlyCellValue and TimeOnlyCellValue #1119
Conversation
tonyqus
commented
Jul 16, 2023
•
edited
Loading
edited
- Change DateTimeCellValue from type DateTime to DateTime?
- Change behavior of getting DateTime cell value - return null if the cell type is not numeric or formula
- Add DateOnlyCellValue property to ICell
- Add TimeOnlyCellValue property to ICell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some feedback to reduce copy-pasting. Also most importantly - the tests fail. It makes no sense to have the tests suite running and helping against regressions if PRs which are not green get merged...
ooxml/XSSF/Streaming/SXSSFCell.cs
Outdated
public DateOnly? DateOnlyCellValue | ||
{ | ||
get{ | ||
if (CellType == CellType.Blank||CellType == CellType.String||CellType == CellType.Boolean||CellType == CellType.Error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems that this code gets repeated a log and only this different is the last like, whether to get DateOnly or TimeOnly, maybe could extract helper for the beginning part?
} | ||
double value = NumericCellValue; | ||
bool date1904 = Sheet.Workbook.IsDate1904(); | ||
return DateOnly.FromDateTime(DateUtil.GetJavaDate(value, date1904)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repetition again, could it just be:
var dateTime = DateUtil.FromCellValue(this);
return DateOnly.FromDateTime(DateUtil.GetJavaDate(value, date1904));