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..40af18e8a06 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 @@ -79,8 +79,8 @@ 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.Sheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.Row; @@ -1554,9 +1554,9 @@ public void generateResultAsPdf(String filter, boolean showClosedProcesses, bool try (OutputStream out = response.getResponseOutputStream()) { SearchResultGeneration sr = new SearchResultGeneration(filter, showClosedProcesses, showInactiveProjects); - HSSFWorkbook wb = sr.getResult(); + XSSFWorkbook wb = sr.getResult(); List> rowList = new ArrayList<>(); - HSSFSheet mySheet = wb.getSheetAt(0); + Sheet mySheet = wb.getSheetAt(0); Iterator rowIter = mySheet.rowIterator(); while (rowIter.hasNext()) { HSSFRow myRow = (HSSFRow) rowIter.next(); @@ -1596,11 +1596,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();