diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java b/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java index 34a9acd64ef..682b637dc43 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java @@ -16,9 +16,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.RangeQueryBuilder; import org.elasticsearch.search.sort.SortOrder; @@ -56,7 +56,7 @@ public SearchResultGeneration(String filter, boolean showClosedProcesses, boolea * * @return HSSFWorkbook */ - public HSSFWorkbook getResult() { + public XSSFWorkbook getResult() { return getWorkbook(); } @@ -96,11 +96,11 @@ public BoolQueryBuilder getQueryForFilter(ObjectType objectType) { return query; } - private HSSFWorkbook getWorkbook() { - HSSFWorkbook workbook = new HSSFWorkbook(); - HSSFSheet sheet = workbook.createSheet("Search results"); + private XSSFWorkbook getWorkbook() { + XSSFWorkbook workbook = new XSSFWorkbook(); + Sheet sheet = workbook.createSheet("Search results"); - HSSFRow title = sheet.createRow(0); + Row title = sheet.createRow(0); title.createCell(0).setCellValue(this.filter); for (int i = 1; i < 8; i++) { title.createCell(i).setCellValue(""); @@ -113,7 +113,7 @@ private HSSFWorkbook getWorkbook() { return workbook; } - private void insertRowData(HSSFSheet sheet) { + private void insertRowData(Sheet sheet) { int rowCounter = 2; long numberOfProcessedProcesses = 0; int elasticsearchLimit = 9999; @@ -149,8 +149,8 @@ private void insertRowData(HSSFSheet sheet) { } } - private void setRowHeader(HSSFSheet sheet) { - HSSFRow rowHeader = sheet.createRow(1); + private void setRowHeader(Sheet sheet) { + Row rowHeader = sheet.createRow(1); rowHeader.createCell(0).setCellValue(Helper.getTranslation("title")); rowHeader.createCell(1).setCellValue(Helper.getTranslation("ID")); rowHeader.createCell(2).setCellValue(Helper.getTranslation("Datum")); @@ -161,8 +161,8 @@ private void setRowHeader(HSSFSheet sheet) { rowHeader.createCell(7).setCellValue(Helper.getTranslation("Status")); } - private void prepareRow(int rowCounter, HSSFSheet sheet, ProcessDTO processDTO) { - HSSFRow row = sheet.createRow(rowCounter); + private void prepareRow(int rowCounter, Sheet sheet, ProcessDTO processDTO) { + Row row = sheet.createRow(rowCounter); row.createCell(0).setCellValue(processDTO.getTitle()); row.createCell(1).setCellValue(processDTO.getId()); row.createCell(2).setCellValue(processDTO.getCreationDate()); diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java index b813448d4cb..db60510b0d3 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java @@ -77,13 +77,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.search.join.ScoreMode; -import org.apache.poi.hssf.usermodel.HSSFCell; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.MatchQueryBuilder; import org.elasticsearch.index.query.MultiMatchQueryBuilder; @@ -1554,16 +1552,16 @@ public void generateResultAsPdf(String filter, boolean showClosedProcesses, bool try (OutputStream out = response.getResponseOutputStream()) { SearchResultGeneration sr = new SearchResultGeneration(filter, showClosedProcesses, showInactiveProjects); - HSSFWorkbook wb = sr.getResult(); - List> rowList = new ArrayList<>(); - HSSFSheet mySheet = wb.getSheetAt(0); + XSSFWorkbook wb = sr.getResult(); + List> rowList = new ArrayList<>(); + Sheet mySheet = wb.getSheetAt(0); Iterator rowIter = mySheet.rowIterator(); while (rowIter.hasNext()) { - HSSFRow myRow = (HSSFRow) rowIter.next(); + Row myRow = (Row) rowIter.next(); Iterator cellIter = myRow.cellIterator(); - List row = new ArrayList<>(); + List row = new ArrayList<>(); while (cellIter.hasNext()) { - HSSFCell myCell = (HSSFCell) cellIter.next(); + Cell myCell = (Cell) cellIter.next(); row.add(myCell); } rowList.add(row); @@ -1596,11 +1594,11 @@ public void generateResult(String filter, boolean showClosedProcesses, boolean s throws IOException { FacesContext facesContext = FacesContext.getCurrentInstance(); if (!facesContext.getResponseComplete()) { - ExternalContext response = prepareHeaderInformation(facesContext, "search.xls"); + ExternalContext response = prepareHeaderInformation(facesContext, "search.xlsx"); try (OutputStream out = response.getResponseOutputStream()) { SearchResultGeneration sr = new SearchResultGeneration(filter, showClosedProcesses, showInactiveProjects); - HSSFWorkbook wb = sr.getResult(); + XSSFWorkbook wb = sr.getResult(); wb.write(out); out.flush(); facesContext.responseComplete(); @@ -1642,15 +1640,15 @@ private ExternalContext prepareHeaderInformation(FacesContext facesContext, Stri return externalContext; } - private PdfPTable getPdfTable(List> rowList) throws DocumentException { + private PdfPTable getPdfTable(List> rowList) throws DocumentException { // create formatter for cells with default locale DataFormatter formatter = new DataFormatter(); PdfPTable table = new PdfPTable(8); table.setSpacingBefore(20); table.setWidths(new int[] {4, 1, 2, 1, 1, 1, 2, 2 }); - for (List row : rowList) { - for (HSSFCell hssfCell : row) { + for (List row : rowList) { + for (Cell hssfCell : row) { String stringCellValue = formatter.formatCellValue(hssfCell); table.addCell(stringCellValue); }