Skip to content

Commit

Permalink
Sortable dates for XLSX outputs (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
akrupnov authored May 1, 2024
1 parent 64a0f75 commit ad43998
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion StatementParser/StatementParserCLI/Output.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ private void SetRowValues(IRow row, ICollection<string> rowValues)
{
var cell = row.CreateCell(columnIndex);

cell.SetCellValue(rowValue);
if(DateTime.TryParse(rowValue, out var dateValue))
{
cell.SetCellValue(dateValue.ToString("s"));
}
else
{
cell.SetCellValue(rowValue);
}

columnIndex++;
}
Expand Down
5 changes: 5 additions & 0 deletions StatementParser/TaxReporterCLI/Output.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ private IRow CreateRow(ISheet sheet, int rowIndex, IList<string> rowValues)
{
cell.SetCellValue((double)value);
}
//For dates using the sortable format so excel can treat it better or at least sort as a string
else if(DateTime.TryParse(rowValue, out var dateValue))
{
cell.SetCellValue(dateValue.ToString("s"));
}
else
{
cell.SetCellValue(rowValue);
Expand Down

0 comments on commit ad43998

Please sign in to comment.