Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add DateOnlyCellValue and TimeOnlyCellValue #1119

Merged
merged 7 commits into from
Jul 26, 2023

Conversation

tonyqus
Copy link
Member

@tonyqus tonyqus commented Jul 16, 2023

  • 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

Copy link
Collaborator

@lahma lahma left a 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...

public DateOnly? DateOnlyCellValue
{
get{
if (CellType == CellType.Blank||CellType == CellType.String||CellType == CellType.Boolean||CellType == CellType.Error)
Copy link
Collaborator

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));
Copy link
Collaborator

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));

@tonyqus tonyqus modified the milestones: NPOI 2.6.2, NPOI 2.7.0 Jul 22, 2023
@tonyqus tonyqus merged commit fd8103d into master Jul 26, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants