导出excl文档

加粗样式
导出excl 文档 只是打印数据转到excl文档之中
大概就是一个方法 二个util文件 一个pom依赖
public String pyExcel() {
/** 模拟数据开始 /
List<Py_Userhistory> staffs = new ArrayList<Py_Userhistory>();
staffs = rd_biz.getPy(user.getUserNo());
for (Py_Userhistory s : staffs) {
System.out.println(s.getUserNo());
}
Map<String, String> titleMap = new LinkedHashMap<String, String>();
titleMap.put(“orderNo”, “水费/交费单号”);
titleMap.put(“datee”, “时间”);
titleMap.put(“preValue”, “上月表码”);
titleMap.put(“curValue”, “本月表码”);
titleMap.put(“amount”, “用水量”);
titleMap.put(“billMoney”, “应缴水费”);
String sheetName = “信息导出”;
/
* 模拟数据结束 */
System.out.println(“start导出”);
long start = System.currentTimeMillis();
Obj2ExcelUtils.excelExport(staffs, titleMap, sheetName);
long end = System.currentTimeMillis();
System.out.println(“end导出”);
System.out.println(“耗时:” + (end - start) + “ms”);
return NONE;
}
加粗文本 该为数据库里面数据 表 表里面字段 表里面字段相对的名称

poom依赖 :
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>

报错的地方是里面输入的文件报错 因为你还没有帮我资源的二个文件放到项目里面去

还有二个文件 我传了资源上去 copy到util里面的
就可以使用了

猜你喜欢

转载自blog.csdn.net/weixin_42014719/article/details/83058497
今日推荐