2.ExcelSheet
查看代码 package com.***.excel;import lombok.Data;import java.util.List;/** * @description: 导出多个sheet表 * @author: *** * @date: 2022/9/15 */@Datapublic class ExcelSheet { /*** sheet的名称*/ private String fileName; /*** sheet里的标题*/ private String[] handers; /*** sheet里的数据集*/ private List<String[]> dataset; public ExcelSheet(String fileName, String[] handers, List<String[]> dataset) { this.fileName = fileName; this.handers = handers; this.dataset = dataset; }} 三、相关业务代码1.service层
【二 Java之POI导出Excel:多个sheet】/*** 导出开票及运单信息*/ExportInvoiceAndBillVo exportInvoiceAndBillInfo(InvoiceReviewListDto dto);2.impl实现类
实现类里的代码,需要各位根据自己的业务场景进行改动,无非就是将需要导出的数据先查出来,带入模板中,调用工具类的方法导出 。
查看代码 package com.***.vo.invoicereview;import lombok.Data;import java.io.Serializable;import java.util.List;/** * @description: 导出开票和运单信息Vo * @author: *** * @date: 2022/9/19 */@Datapublic class ExportInvoiceAndBillVo implements Serializable { /*** 开票信息*/ private List<String[]> invoiceList; /*** 运单信息*/ private List<String[]> billList;} 查看代码 @Override public ExportInvoiceAndBillVo exportInvoiceAndBillInfo(InvoiceReviewListDto dto) { ExportInvoiceAndBillVo invoiceAndBill = new ExportInvoiceAndBillVo(); // 查询需要导出的开票信息 PageInfo<InvoiceReviewListVo> pageInfo = queryInvoiceReviewList(dto); List<InvoiceReviewListVo> invoiceList = pageInfo.getList(); if (invoiceList.size() > 10000) { throw new ServiceException("开票数据过多,请分批次导出"); } // 查询需要导出的车运运单信息 List<Long> invoiceIdList = invoiceList.stream().map(InvoiceReviewListVo::getInvoiceId).collect(Collectors.toList()); List<ExportBillVo> billList = getBillInfo(invoiceIdList); if (billList.size() > 10000) { throw new ServiceException("运单数据过多,请分批次导出"); } // 将表1 表2的数据 放入定义的对象Vo中 invoiceAndBill.setInvoiceList(getInvoiceDataList(invoiceList)); invoiceAndBill.setBillList(getBillDataList(billList)); return invoiceAndBill; }
经验总结扩展阅读
-
-
-
-
看到一位男网友发帖 明明可以过得很轻松,却偏偏把自己搞得那么累
-
-
-
-
|总要在感情路上跌跌撞撞,才发现旧爱是最美的星座配对
-
7月中旬,相守难,相忘更难,冰释前嫌,重归于好,真爱完璧归赵
-
平底鞋 有种时髦叫“新年烫头”,换这3种卷发去拜年,亲戚都夸你好洋气
-
-
-
-
辅酶q10胶囊早晨还是晚上吃,请问辅酶Q10一天当中什么时候吃最好啊,早上空腹还是中午饭后,还是晚上睡觉前呢????
-
-
-
-
|你能不能一直这么爱我,想要12星座男爱你很久,你要怎么做
-
【幽默笑话】老李既是我的上司又是我老丈人|幽默笑话:女友这人特别的迷信,因为性格急躁耽误了不少事
-