JavaShuo
栏目
标签
EasyPoi导出包含动态列的Excel
时间 2021-08-12
标签
html
ide
code
xml
htm
blog
get
class
栏目
Java开源
繁體版
原文
原文链接
版权声明:本文为博主原创文章,遵循
CC 4.0 BY-SA
版权协议,转载请附上原文出处连接和
<dependency>
<groupId>cn.afterturn </groupId>
<artifactId>easypoi-base </artifactId>
<version>3.2.0 </version>
</dependency>
@Test
public void dynaCol() {
try {
List<ExcelExportEntity> colList = new ArrayList<ExcelExportEntity>();
ExcelExportEntity colEntity = new ExcelExportEntity( "商品名称", "title");
colEntity.setNeedMerge( true);
colList.add(colEntity);
colEntity = new ExcelExportEntity( "供应商", "supplier");
colEntity.setNeedMerge( true);
colList.add(colEntity);
ExcelExportEntity deliColGroup = new ExcelExportEntity( "得力", "deli");
List<ExcelExportEntity> deliColList = new ArrayList<ExcelExportEntity>();
deliColList.add( new ExcelExportEntity( "市场价", "orgPrice"));
deliColList.add( new ExcelExportEntity( "专区价", "salePrice"));
deliColGroup.setList(deliColList);
colList.add(deliColGroup);
ExcelExportEntity jdColGroup = new ExcelExportEntity( "京东", "jd");
List<ExcelExportEntity> jdColList = new ArrayList<ExcelExportEntity>();
jdColList.add( new ExcelExportEntity( "市场价", "orgPrice"));
jdColList.add( new ExcelExportEntity( "专区价", "salePrice"));
jdColGroup.setList(jdColList);
colList.add(jdColGroup);
List< Map< String, Object>> list = new ArrayList< Map< String, Object>>();
for (int i = 0; i < 10; i++) {
Map< String, Object> valMap = new HashMap< String, Object>();
valMap.put( "title", "名称." + i);
valMap.put( "supplier", "供应商." + i);
List< Map< String, Object>> deliDetailList = new ArrayList< Map< String, Object>>();
for (int j = 0; j < 3; j++) {
Map< String, Object> deliValMap = new HashMap< String, Object>();
deliValMap.put( "orgPrice", "得力.市场价." + j);
deliValMap.put( "salePrice", "得力.专区价." + j);
deliDetailList.add(deliValMap);
}
valMap.put( "deli", deliDetailList);
List< Map< String, Object>> jdDetailList = new ArrayList< Map< String, Object>>();
for (int j = 0; j < 2; j++) {
Map< String, Object> jdValMap = new HashMap< String, Object>();
jdValMap.put( "orgPrice", "京东.市场价." + j);
jdValMap.put( "salePrice", "京东.专区价." + j);
jdDetailList.add(jdValMap);
}
valMap.put( "jd", jdDetailList);
list.add(valMap);
}
Workbook workbook = ExcelExportUtil.exportExcel( new ExportParams( "价格分析表", "数据"), colList,
list);
FileOutputStream fos = new FileOutputStream( "D:/价格分析表.tt.xls");
workbook.write(fos);
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
导出结果图
html
版权声明:本文为博主原创文章,遵循
CC 4.0 BY-SA
版权协议,转载请附上原文出处连接和本声明。
<dependency>
<groupId>cn.afterturn </groupId>
<artifactId>easypoi-base </artifactId>
<version>3.2.0 </version>
</dependency>
@Test
public void dynaCol() {
try {
List<ExcelExportEntity> colList = new ArrayList<ExcelExportEntity>();
ExcelExportEntity colEntity = new ExcelExportEntity( "商品名称", "title");
colEntity.setNeedMerge( true);
colList.add(colEntity);
colEntity = new ExcelExportEntity( "供应商", "supplier");
colEntity.setNeedMerge( true);
colList.add(colEntity);
ExcelExportEntity deliColGroup = new ExcelExportEntity( "得力", "deli");
List<ExcelExportEntity> deliColList = new ArrayList<ExcelExportEntity>();
deliColList.add( new ExcelExportEntity( "市场价", "orgPrice"));
deliColList.add( new ExcelExportEntity( "专区价", "salePrice"));
deliColGroup.setList(deliColList);
colList.add(deliColGroup);
ExcelExportEntity jdColGroup = new ExcelExportEntity( "京东", "jd");
List<ExcelExportEntity> jdColList = new ArrayList<ExcelExportEntity>();
jdColList.add( new ExcelExportEntity( "市场价", "orgPrice"));
jdColList.add( new ExcelExportEntity( "专区价", "salePrice"));
jdColGroup.setList(jdColList);
colList.add(jdColGroup);
List< Map< String, Object>> list = new ArrayList< Map< String, Object>>();
for (int i = 0; i < 10; i++) {
Map< String, Object> valMap = new HashMap< String, Object>();
valMap.put( "title", "名称." + i);
valMap.put( "supplier", "供应商." + i);
List< Map< String, Object>> deliDetailList = new ArrayList< Map< String, Object>>();
for (int j = 0; j < 3; j++) {
Map< String, Object> deliValMap = new HashMap< String, Object>();
deliValMap.put( "orgPrice", "得力.市场价." + j);
deliValMap.put( "salePrice", "得力.专区价." + j);
deliDetailList.add(deliValMap);
}
valMap.put( "deli", deliDetailList);
List< Map< String, Object>> jdDetailList = new ArrayList< Map< String, Object>>();
for (int j = 0; j < 2; j++) {
Map< String, Object> jdValMap = new HashMap< String, Object>();
jdValMap.put( "orgPrice", "京东.市场价." + j);
jdValMap.put( "salePrice", "京东.专区价." + j);
jdDetailList.add(jdValMap);
}
valMap.put( "jd", jdDetailList);
list.add(valMap);
}
Workbook workbook = ExcelExportUtil.exportExcel( new ExportParams( "价格分析表", "数据"), colList,
list);
FileOutputStream fos = new FileOutputStream( "D:/价格分析表.tt.xls");
workbook.write(fos);
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
导出结果图
ide
相关文章
1.
EasyPoi动态列导出Excel
2.
使用easypoi导出excel
3.
关于EasyPoi导出Excel
4.
struts2使用easypoi导出excel
5.
easypoi-Springboot 导出数据Excel
6.
easyPoi导出excel导出错误
7.
springmvc使用easypoi导出导入Excel表(1):导出Excel表
8.
easyPOI + SpringBoot导入与导出Excel
9.
好用的Excel导出工具—EasyPOI
10.
java快速搞定excel导出(easypoi)
更多相关文章...
•
PHP 包含文件
-
PHP教程
•
C# 动态数组(ArrayList)
-
C#教程
•
算法总结-滑动窗口
•
使用阿里云OSS+CDN部署前端页面与加速静态资源
相关标签/搜索
easypoi
包含
Excel导出数据
动态
导出
出包
excel
包含在内
出动
HTML
Java开源
XML
Microsoft Office
红包项目实战
NoSQL教程
PHP教程
静态资源
0
分享到微博
分享到微信
分享到QQ
每日一句
每一个你不满意的现在,都有一个你没有努力的曾经。
最新文章
1.
vs2019运行opencv图片显示代码时,窗口乱码
2.
app自动化 - 元素定位不到?别慌,看完你就能解决
3.
在Win8下用cisco ××× Client连接时报Reason 422错误的解决方法
4.
eclipse快速补全代码
5.
Eclipse中Java/Html/Css/Jsp/JavaScript等代码的格式化
6.
idea+spring boot +mabitys(wanglezapin)+mysql (1)
7.
勒索病毒发生变种 新文件名将带有“.UIWIX”后缀
8.
【原创】Python 源文件编码解读
9.
iOS9企业部署分发问题深入了解与解决
10.
安装pytorch报错CondaHTTPError:******
本站公众号
欢迎关注本站公众号,获取更多信息
相关文章
1.
EasyPoi动态列导出Excel
2.
使用easypoi导出excel
3.
关于EasyPoi导出Excel
4.
struts2使用easypoi导出excel
5.
easypoi-Springboot 导出数据Excel
6.
easyPoi导出excel导出错误
7.
springmvc使用easypoi导出导入Excel表(1):导出Excel表
8.
easyPOI + SpringBoot导入与导出Excel
9.
好用的Excel导出工具—EasyPOI
10.
java快速搞定excel导出(easypoi)
>>更多相关文章<<