From 1a9f8bd8883d98c9b6da29345acddece9cc44825 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Thu, 5 Aug 2021 17:26:32 -0400 Subject: [PATCH] Bug fix for dates in Excel file --- .../datasourcesummaryexport/Bundle.properties-MERGED | 1 - .../report/modules/datasourcesummaryexport/CellModel.java | 6 ++++++ .../modules/datasourcesummaryexport/DefaultCellModel.java | 7 +++++++ .../modules/datasourcesummaryexport/ExcelExport.java | 4 ++-- .../modules/datasourcesummaryexport/ExportRecentFiles.java | 3 +-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/Bundle.properties-MERGED index 6c96e246b0..42143965be 100755 --- a/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/Bundle.properties-MERGED @@ -15,4 +15,3 @@ ExportRecentFiles_col_header_path=Path ExportRecentFiles_col_header_sender=Sender ExportRecentFiles_docsTable_tabName=Recently Opened Documents ExportRecentFiles_downloadsTable_tabName=Recently Downloads -ExportRecentFiles_emailParserModuleName=Email Parser diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/CellModel.java b/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/CellModel.java index bae7d770b7..ce072525ea 100755 --- a/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/CellModel.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/CellModel.java @@ -82,4 +82,10 @@ interface CellModel { * @return The horizontal alignment for the text in the cell. */ HorizontalAlign getHorizontalAlignment(); + + /** + * @return The format string to be used with Apache POI during excel + * export or null if none necessary. + */ + String getExcelFormatString(); } diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/DefaultCellModel.java b/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/DefaultCellModel.java index 149d3413f6..c2e2b7d085 100755 --- a/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/DefaultCellModel.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/DefaultCellModel.java @@ -27,6 +27,7 @@ class DefaultCellModel implements CellModel { private final T data; private final String text; private CellModel.HorizontalAlign horizontalAlignment; + private final String excelFormatString; /** * Main constructor. @@ -62,6 +63,7 @@ class DefaultCellModel implements CellModel { */ DefaultCellModel(T data, Function stringConverter, String excelFormatString) { this.data = data; + this.excelFormatString = excelFormatString; if (stringConverter == null) { text = this.data == null ? "" : this.data.toString(); @@ -84,6 +86,11 @@ class DefaultCellModel implements CellModel { public HorizontalAlign getHorizontalAlignment() { return horizontalAlignment; } + + @Override + public String getExcelFormatString() { + return this.excelFormatString; + } /** * Sets the horizontal alignment for this cell model. diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/ExcelExport.java b/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/ExcelExport.java index 4cc589bba8..47087dd985 100644 --- a/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/ExcelExport.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/ExcelExport.java @@ -324,8 +324,8 @@ class ExcelExport { static Cell createCell(WorksheetEnv env, Row row, int colNum, CellModel cellModel, Optional cellStyle) { CellStyle cellStyleToUse = cellStyle.orElse(env.getDefaultCellStyle()); - if (cellModel.getText() != null || cellModel.getHorizontalAlignment() != null) { - cellStyleToUse = env.getCellStyle(new CellStyleKey(cellModel.getText(), cellStyleToUse, cellModel.getHorizontalAlignment())); + if (cellModel.getExcelFormatString() != null || cellModel.getHorizontalAlignment() != null) { + cellStyleToUse = env.getCellStyle(new CellStyleKey(cellModel.getExcelFormatString(), cellStyleToUse, cellModel.getHorizontalAlignment())); } Object cellData = cellModel.getData(); diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/ExportRecentFiles.java b/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/ExportRecentFiles.java index 2b9f244d3f..1864dc5332 100755 --- a/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/ExportRecentFiles.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/datasourcesummaryexport/ExportRecentFiles.java @@ -44,8 +44,7 @@ import org.sleuthkit.datamodel.DataSource; "ExportRecentFiles_col_head_date=Date", "ExportRecentFiles_col_header_domain=Domain", "ExportRecentFiles_col_header_path=Path", - "ExportRecentFiles_col_header_sender=Sender", - "ExportRecentFiles_emailParserModuleName=Email Parser" + "ExportRecentFiles_col_header_sender=Sender" }) final class ExportRecentFiles {