当前位置:网站首页>poi导出excel,行相同数据自动合并单元格
poi导出excel,行相同数据自动合并单元格
2022-04-23 05:38:00 【wyazyf】
/**
*excel行自动合并
*listData 待导出数据
*/
public void test(SXSSFSheet sheet,List<FanManagerExt> listData){
//备份上一条数据
FanManagerExt entityOld = new FanManagerExt();
for(int i=0;i<listData.size();i++){
//当前行数据
FanManagerExt entity= listData.get(i);
//实体字段集合(有序)
Field[] fields = entity.getClass().getDeclaredFields();
Field[] fieldOld = entityOld.getClass().getDeclaredFields();
for(int a=0;a<fields.length;a++){
fields[a].setAccessible(true);
fieldOld[a].setAccessible(true);
//将上下两行同列数据强制转换为字符串进行比较,相同设置单元格合并
try {
if(String.valueOf(fieldOld[a].get(entityOld)).equals(String.valueOf(fields[a].get(entity)))){
CellRangeAddress cra=new CellRangeAddress(i, i+1, a+1, a+1);
//在sheet里设置合并单元格
sheet.addMergedRegion(cra);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
//对象深拷贝
BeanUtils.copyProperties(entity,entityOld);
}
}
版权声明
本文为[wyazyf]所创,转载请带上原文链接,感谢
https://blog.csdn.net/wyazyf/article/details/120194495
边栏推荐
- 世界与个人发展
- catkin_package到底干了什么
- Radar equipment (greedy)
- World and personal development
- 弘玑微课堂 | Cyclone RPA之“灵活的数字员工”执行器
- qt. qpa. plugin: Could not find the Qt platform plugin “xcb“ in ““
- On the use of constant pointer and pointer constant -- exercise (record)
- JSON.
- Branch and loop statements
- Nécessité de précharger les cookies dans le sélénium
猜你喜欢

Data mining -- understanding data

uni使用的一些坑

C# ,类库

弘玑微课堂 | Cyclone RPA之“灵活的数字员工”执行器

Double click The jar package cannot run the solution

Flutter 新一代圖形渲染器 Impeller

The title bar will be pushed to coincide with the status bar

弘玑Cyclone RPA为国金证券提供技术支撑,超200个业务场景实现流程自动化

QT displays the specified position and size of the picture

Branch and loop statements
随机推荐
弘玑微课堂 | Cyclone RPA之“灵活的数字员工”执行器
[triangle Yang Hui triangle printing odd even cycle JS for break cycle]
CMake基础教程(39)pkgconfig
The QT debug version runs normally and the release version runs crash
Use of ES6 array
Flutter 新一代图形渲染器 Impeller
Contract lock loophole
On the use of constant pointer and pointer constant -- exercise (record)
可执行程序执行流程
STD:: String implements split
After adding qmenu to qtoolbutton and QPushButton, remove the triangle icon in the lower right corner
mysql中duplicate key update
acwing854. Floyd finds the shortest path
STL learning notes 0x0001 (container classification)
If I am PM's performance, movie VR ticket purchase display
Step on the pit: Nacos uses startup CMD - M standalone startup error
‘EddiesObservations‘ object has no attribute ‘filled‘
转置卷积(Transposed Convolution)
College entrance examination volunteer filling reference
Range of numbers (dichotomous classic template topic)