Comments (1)
我也遇到了这个问题,不过现在已经解决了需要加个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;
}
}
}
}
from easyexcel.
Related Issues (20)
- this_x7c82__map写入到excel中会变更 this粂_map HOT 1
- 单元格中含有html样式代码导出
- eclipse搭建3.3.4,所需要的jar包?自己配置,总是版本冲突。希望博主能列一个清单或者出一个exclipse搭建该环境的指南 HOT 2
- 生成的自定义颜色与设置的不一致 HOT 2
- 使用模板填充的方式可以动态删除某一列吗
- easyExcel读取函数列时会将所有列值读取为0,就是那列有sum等这种函数的情况下会读取失败 HOT 1
- 多列表填充若同一列有两个列表数据源,填充后两个列表数据展示错乱 HOT 1
- 不创建对象用String接收日期类型数据异常 HOT 2
- 模板导出列表格式有误
- 数据写入CSV文件异常:Can not close IO HOT 2
- 导出的excel一开始是5kb,保存后变成11kb HOT 1
- 获取Excel的总行数 HOT 1
- 测试类中写入表格数据丢失 HOT 1
- 分批填充,当EasyExcel.write(arg)参数为ByteArrayOutputStream时,ByteArrayOutputStream为空的 HOT 1
- @ColumnWidth 无效 HOT 1
- 使用ExcelWriter#fill方法进行填充list数据时,存在问题会使不同行的数据错乱 HOT 1
- easyexcel是否可以使用外部字体文件并再导出的字体文件内内嵌外部字体文件
- 3.x版本 文件流无法释放 导致tomcat删除缓存文件失败,其中EasyExcel.read()第一个参数传file或者inputStream 都不行 HOT 2
- 模版填充不能用 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyexcel.