Merge branch 'DM-578-convert' into 'master'

DM-578 - Use DataFormatter to prevent error when reading cell value

Closes DM-578

See merge request redactmanager/redaction-report-service!30
This commit is contained in:
Andrei Isvoran 2023-11-20 09:50:49 +01:00
commit 9882a9ae9b

View File

@ -8,6 +8,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
@ -37,6 +38,7 @@ public class ScmReportService {
ComponentClient componentResource;
FileAttributesConfigClient fileAttributesClient;
DataFormatter formatter = new DataFormatter();
public void addScmRows(Sheet sheet, FileModel fileModel, ExcelModel excelModel) {
@ -197,7 +199,7 @@ public class ScmReportService {
var iterator = firstRow.cellIterator();
while (iterator.hasNext()) {
Cell cell = iterator.next();
String cellValue = cell.getStringCellValue();
String cellValue = formatter.formatCellValue(cell);
if (fileAttributes.containsKey(cellValue)) {
fileAttributeModels.add(FileAttributeModel.builder().id(fileAttributes.get(cellValue)).cell(cell).build());
}