Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public static Headers readHeaders(LoggerHelper LOGGER, XSSFSheet sheet) throws I
int rowZeroWidth = sheet.getRow(0).getLastCellNum();
for (int i = 0; i < rowZeroWidth; i++) {
XSSFCell cell = sheet.getRow(0).getCell(i);
if (cell == null) {
LOGGER.atWarn("Cell in header row at zero-indexed column "+i+" is null, skipping...");
continue;
}
CellType cellType = cell.getCellType();
if (cellType == CellType._NONE || cellType == CellType.BLANK || cellType == CellType.ERROR) {
LOGGER.atWarn("Cell in header row at zero-indexed column "+i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,27 @@ private Condition readCondition(XSSFCell cell) throws InvalidConditionValueExcep
}
}

private boolean isCellInMergedRegion(XSSFCell cell) {
XSSFSheet sheet = cell.getSheet();
int rowIndex = cell.getRowIndex();
int colIndex = cell.getColumnIndex();
return sheet.getMergedRegions().stream().anyMatch(region -> region.isInRange(rowIndex, colIndex));
}

private Strain readStrain(XSSFCell cell, Condition condition) throws InvalidStrainValueException {
int rowIndex = cell.getRowIndex();
int colIndex = cell.getColumnIndex();
// Check if the cell is in a merged region
if (cell == null || isCellInMergedRegion(cell)) {
while (cell == null || cell.getCellType() == CellType.BLANK || cell.getCellType() == CellType.ERROR) {
if (rowIndex == 0) break;
rowIndex--;
cell = cell.getSheet().getRow(rowIndex).getCell(colIndex);
rowIndex = cell.getRowIndex();
colIndex = cell.getColumnIndex();
}
}

CellType cellType = cell.getCellType();
if (cellType == CellType.STRING) {
String cellContent = cell.getStringCellValue();
Expand All @@ -265,8 +285,6 @@ private Strain readStrain(XSSFCell cell, Condition condition) throws InvalidStra
strains.add(newStrain);
return newStrain;
} else if (cellType == CellType.BLANK || cellType == CellType._NONE) {
int rowIndex = cell.getRowIndex();
int colIndex = cell.getColumnIndex();
for (int i = rowIndex - 1; i > 1; i--) {
XSSFCell nextCell = cell.getSheet().getRow(i).getCell(colIndex);
if (nextCell.getCellType() == CellType.STRING) return readStrain(nextCell, condition);
Expand Down