Skip to content

Add DateOnlyCellValue and TimeOnlyCellValue#1119

Merged
tonyqus merged 7 commits into
masterfrom
Enable-getting-DateOnly-CellValue
Jul 26, 2023
Merged

Add DateOnlyCellValue and TimeOnlyCellValue#1119
tonyqus merged 7 commits into
masterfrom
Enable-getting-DateOnly-CellValue

Conversation

@tonyqus
Copy link
Copy Markdown
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
Copy Markdown
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...

Comment thread main/HSSF/UserModel/HSSFCell.cs Outdated
Comment thread main/HSSF/UserModel/HSSFCell.cs Outdated
Comment thread ooxml/XSSF/Streaming/SXSSFCell.cs Outdated
public DateOnly? DateOnlyCellValue
{
get{
if (CellType == CellType.Blank||CellType == CellType.String||CellType == CellType.Boolean||CellType == CellType.Error)
Copy link
Copy Markdown
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
Copy Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants