|
|
@ -295,34 +295,9 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { |
|
|
|
default: |
|
|
|
default: |
|
|
|
throw new ExcelGenerateException("The wrong direction."); |
|
|
|
throw new ExcelGenerateException("The wrong direction."); |
|
|
|
} |
|
|
|
} |
|
|
|
Row row = sheet.getRow(lastRowIndex); |
|
|
|
|
|
|
|
if (row == null) { |
|
|
|
Row row = createRowIfNecessary(sheet, cachedSheet, lastRowIndex, fillConfig, analysisCell, isOriginalCell); |
|
|
|
row = cachedSheet.getRow(lastRowIndex); |
|
|
|
Cell cell = createCellIfNecessary(row,lastColumnIndex); |
|
|
|
if (row == null) { |
|
|
|
|
|
|
|
WriteHandlerUtils.beforeRowCreate(writeContext, lastRowIndex, null, Boolean.FALSE); |
|
|
|
|
|
|
|
if (fillConfig.getForceNewRow()) { |
|
|
|
|
|
|
|
row = cachedSheet.createRow(lastRowIndex); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// The last row of the middle disk inside empty rows, resulting in cachedSheet can not get inside.
|
|
|
|
|
|
|
|
// Will throw Attempting to write a row[" + rownum + "] " + "in the range [0," + this._sh.getLastRowNum() + "] that is already written to disk.
|
|
|
|
|
|
|
|
try{ |
|
|
|
|
|
|
|
row = sheet.createRow(lastRowIndex); |
|
|
|
|
|
|
|
}catch (IllegalArgumentException ignore){ |
|
|
|
|
|
|
|
row = cachedSheet.createRow(lastRowIndex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
checkRowHeight(analysisCell, fillConfig, isOriginalCell, row); |
|
|
|
|
|
|
|
WriteHandlerUtils.afterRowCreate(writeContext, row, null, Boolean.FALSE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
checkRowHeight(analysisCell, fillConfig, isOriginalCell, row); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Cell cell = row.getCell(lastColumnIndex); |
|
|
|
|
|
|
|
if (cell == null) { |
|
|
|
|
|
|
|
WriteHandlerUtils.beforeCellCreate(writeContext, row, null, lastColumnIndex, null, Boolean.FALSE); |
|
|
|
|
|
|
|
cell = row.createCell(lastColumnIndex); |
|
|
|
|
|
|
|
WriteHandlerUtils.afterCellCreate(writeContext, cell, null, null, Boolean.FALSE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<AnalysisCell, CellStyle> collectionFieldStyleMap = collectionFieldStyleCache.get(currentUniqueDataFlag); |
|
|
|
Map<AnalysisCell, CellStyle> collectionFieldStyleMap = collectionFieldStyleCache.get(currentUniqueDataFlag); |
|
|
|
if (collectionFieldStyleMap == null) { |
|
|
|
if (collectionFieldStyleMap == null) { |
|
|
@ -340,6 +315,45 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { |
|
|
|
return cell; |
|
|
|
return cell; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Cell createCellIfNecessary(Row row, Integer lastColumnIndex) { |
|
|
|
|
|
|
|
Cell cell = row.getCell(lastColumnIndex); |
|
|
|
|
|
|
|
if (cell != null) { |
|
|
|
|
|
|
|
return cell; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
WriteHandlerUtils.beforeCellCreate(writeContext, row, null, lastColumnIndex, null, Boolean.FALSE); |
|
|
|
|
|
|
|
cell = row.createCell(lastColumnIndex); |
|
|
|
|
|
|
|
WriteHandlerUtils.afterCellCreate(writeContext, cell, null, null, Boolean.FALSE); |
|
|
|
|
|
|
|
return cell; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Row createRowIfNecessary(Sheet sheet, Sheet cachedSheet, Integer lastRowIndex, FillConfig fillConfig, |
|
|
|
|
|
|
|
AnalysisCell analysisCell, boolean isOriginalCell) { |
|
|
|
|
|
|
|
Row row = sheet.getRow(lastRowIndex); |
|
|
|
|
|
|
|
if (row != null) { |
|
|
|
|
|
|
|
return row; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
row = cachedSheet.getRow(lastRowIndex); |
|
|
|
|
|
|
|
if (row == null) { |
|
|
|
|
|
|
|
WriteHandlerUtils.beforeRowCreate(writeContext, lastRowIndex, null, Boolean.FALSE); |
|
|
|
|
|
|
|
if (fillConfig.getForceNewRow()) { |
|
|
|
|
|
|
|
row = cachedSheet.createRow(lastRowIndex); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// The last row of the middle disk inside empty rows, resulting in cachedSheet can not get inside.
|
|
|
|
|
|
|
|
// Will throw Attempting to write a row[" + rownum + "] " + "in the range [0," + this._sh.getLastRowNum() + "] that is already written to disk.
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
row = sheet.createRow(lastRowIndex); |
|
|
|
|
|
|
|
} catch (IllegalArgumentException ignore) { |
|
|
|
|
|
|
|
row = cachedSheet.createRow(lastRowIndex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
checkRowHeight(analysisCell, fillConfig, isOriginalCell, row); |
|
|
|
|
|
|
|
WriteHandlerUtils.afterRowCreate(writeContext, row, null, Boolean.FALSE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
checkRowHeight(analysisCell, fillConfig, isOriginalCell, row); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return row; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void checkRowHeight(AnalysisCell analysisCell, FillConfig fillConfig, boolean isOriginalCell, Row row) { |
|
|
|
private void checkRowHeight(AnalysisCell analysisCell, FillConfig fillConfig, boolean isOriginalCell, Row row) { |
|
|
|
if (!analysisCell.getFirstRow() || !WriteDirectionEnum.VERTICAL.equals(fillConfig.getDirection())) { |
|
|
|
if (!analysisCell.getFirstRow() || !WriteDirectionEnum.VERTICAL.equals(fillConfig.getDirection())) { |
|
|
|
return; |
|
|
|
return; |
|
|
|