We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如图:
版本:3.3.2
The text was updated successfully, but these errors were encountered:
我也遇到了这个问题,不过现在已经解决了需要加个Handler: EasyExcel.write(file).withTemplate(template).registerWriteHandler(new CellHandler()).build()
public class CellHandler extends AbstractMergeStrategy {
CellStyle cellStyle;
@OverRide protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) { if (relativeRowIndex == null || relativeRowIndex == 0) { return; } int rowIndex = cell.getRowIndex(); int colIndex = cell.getColumnIndex(); Sheet thisSheet = cell.getSheet(); Row preRow = thisSheet.getRow(rowIndex - 1); Row thisRow = thisSheet.getRow(rowIndex); Cell preCell = preRow.getCell(colIndex);// 获取上一行的该格 Cell tmpCell; List list = thisSheet.getMergedRegions();
for (int i = 0; i < list.size(); i++) { CellRangeAddress cellRangeAddress = list.get(i); if (cellRangeAddress.containsRow(preCell.getRowIndex()) && cellRangeAddress.containsColumn(preCell.getColumnIndex())) { int lastColIndex = cellRangeAddress.getLastColumn(); int firstColIndex = cellRangeAddress.getFirstColumn(); CellRangeAddress cra = new CellRangeAddress(cell.getRowIndex(), cell.getRowIndex(), firstColIndex, lastColIndex); thisSheet.addMergedRegion(cra); for (int j = firstColIndex; j <= lastColIndex; j++) { tmpCell = thisRow.getCell(j); if (tmpCell == null) { tmpCell = thisRow.createCell(j); } tmpCell.setCellStyle(preRow.getCell(j).getCellStyle()); } return; } }
} }
Sorry, something went wrong.
zhuangjiaju
No branches or pull requests
如图:
版本:3.3.2
The text was updated successfully, but these errors were encountered: