Skip to content

Commit

Permalink
use correct methods
Browse files Browse the repository at this point in the history
  • Loading branch information
KochTobi committed Sep 17, 2024
1 parent aec0f86 commit 5cdefa3
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package life.qbic.datamanager.views.projects.project.measurements.download;

import static life.qbic.datamanager.spreadsheet.XLSXTemplateHelper.createOptionArea;
import static life.qbic.datamanager.spreadsheet.XLSXTemplateHelper.getOrCreateCell;
import static life.qbic.datamanager.spreadsheet.XLSXTemplateHelper.getOrCreateRow;
import static life.qbic.datamanager.spreadsheet.XLSXTemplateHelper.hideSheet;
import static life.qbic.datamanager.spreadsheet.XLSXTemplateHelper.lockSheet;
import static life.qbic.logging.service.LoggerFactory.logger;
Expand All @@ -10,7 +12,6 @@
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import life.qbic.application.commons.ApplicationException;
import life.qbic.application.commons.ApplicationException.ErrorCode;
import life.qbic.datamanager.spreadsheet.XLSXTemplateHelper;
Expand All @@ -25,7 +26,6 @@
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.DefaultIndexedColorMap;
Expand Down Expand Up @@ -180,7 +180,7 @@ public byte[] getContent() {

Row header = getOrCreateRow(sheet, 0);
for (NGSMeasurementColumns value : NGSMeasurementColumns.values()) {
var cell = header.createCell(value.columnIndex());
var cell = getOrCreateCell(header, value.columnIndex());
cell.setCellValue(value.headerName());
setHeaderStyle(cell, value.readOnly());
}
Expand Down Expand Up @@ -224,16 +224,6 @@ public byte[] getContent() {
return byteArrayOutputStream.toByteArray();
}

private static Row getOrCreateRow(Sheet sheet, int index) {
return Optional.ofNullable(sheet.getRow(index))
.orElse(sheet.createRow(index));
}

private static Cell getOrCreateCell(Row row, int colIndex) {
return Optional.ofNullable(row.getCell(colIndex, MissingCellPolicy.RETURN_BLANK_AS_NULL))
.orElse(row.createCell(colIndex));
}

@Override
public String getFileName() {
return String.join("_", fileNamePrefix, FILE_NAME_SUFFIX);
Expand Down

0 comments on commit 5cdefa3

Please sign in to comment.