easypoi复杂标题导出

更新时间:2023-07-03 09:27:27 阅读: 评论:0

easypoi复杂标题导出1.⼯具类
/**
* Copyright 2013-2015 JueYue (qrb.)
*
*  Licend under the Apache Licen, Version 2.0 (the "Licen");
*  you may not u this file except in compliance with the Licen.
*  You may obtain a copy of the Licen at
*
*    www.apache/licens/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
* distributed under the Licen is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licen for the specific language governing permissions and
* limitations under the Licen.
*/
package cn.l;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.poi.hssf.urmodel.HSSFWorkbook;
import org.apache.poi.ss.urmodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.urmodel.XSSFWorkbook;
import cn.l.entity.ExportParams;
import cn.l.entity.TemplateExportParams;
import cn.us.ExcelType;
import cn.l.entity.params.ExcelExportEntity;
import cn.l.export.ExcelBatchExportService;
import cn.l.export.ExcelExportService;
import cn.plate.ExcelExportOfTemplateUtil;
/**
* excel 导出⼯具类
*tonguetwister
* @author JueYue
* @version 1.0
*  2013-10-17
*/
public final class ExcelExportUtil {
private ExcelExportUtil() {
}
/**
* @param entity
感恩节英语*            表格标题属性
* @param pojoClass
*            Excel对象Classusually是什么意思
* @param dataSet
*            Excel对象数据List
*/
public static Workbook exportBigExcel(ExportParams entity, Class<?> pojoClass,
Collection<?> dataSet) {
ExcelBatchExportService batchService = ExcelBatchExportService
.getExcelBatchExportService(entity, pojoClass);
return batchService.appendData(dataSet);
}
public static Workbook exportBigExcel(ExportParams entity, List<ExcelExportEntity> excelParams,
Collection<?> dataSet) {
ExcelBatchExportService batchService = ExcelBatchExportService
.getExcelBatchExportService(entity, excelParams);
return batchService.appendData(dataSet);
}
public static void cloExportBigExcel() {
ExcelBatchExportService batchService = CurrentExcelBatchExportService();        if(batchService != null) {
batchService.cloExportBigExcel();
}
}
/**
* @param entity
*            表格标题属性
* @param pojoClass
*            Excel对象Class
* @param dataSet
*            Excel对象数据List
*/
public static Workbook exportExcel(ExportParams entity, Class<?> pojoClass,
Collection<?> dataSet) {
Workbook workbook = Type(),dataSet.size());
new ExcelExportService().createSheet(workbook, entity, pojoClass, dataSet);
return workbook;
}
private static Workbook getWorkbook(ExcelType type, int size) {
if (ExcelType.HSSF.equals(type)) {
return new HSSFWorkbook();
} el if (size < 100000) {
return new XSSFWorkbook();
} el {
return new SXSSFWorkbook();
}
}
/**
* 根据Map创建对应的Excel
* @param entity
*            表格标题属性
* @param entityList
*            Map对象列表
* @param dataSet
*            Excel对象数据List
*/
public static Workbook exportExcel(ExportParams entity, List<ExcelExportEntity> entityList,
Collection<?> dataSet) {
Workbook workbook = Type(),dataSet.size());;
new ExcelExportService().createSheetForMap(workbook, entity, entityList, dataSet);
return workbook;
}
/**
* ⼀个excel 创建多个sheet
*
* @param listcollecting
*            多个Map key title 对应表格Title key entity 对应表格对应实体 key data
*            Collection 数据
* @return
*/
public static Workbook exportExcel(List<Map<String, Object>> list, ExcelType type) {
Workbook workbook = getWorkbook(type,0);definition
Workbook workbook = getWorkbook(type,0);
for (Map<String, Object> map : list) {
ExcelExportService rvice = new ExcelExportService();
(Class<?>) ("entity"), (Collection<?>) ("data"));
}
return workbook;
}
/**
* 导出⽂件通过模板解析,不推荐这个了,推荐全部通过模板来执⾏处理
*
* @param params
*            导出参数类
* @param pojoClassmanagement缩写
*            对应实体
* @param dataSet
*            实体集合
* @param map
*            模板集合
* @return
*/
@Deprecated
public static Workbook exportExcel(TemplateExportParams params, Class<?> pojoClass,
Collection<?> dataSet, Map<String, Object> map) {
return new ExcelExportOfTemplateUtil().createExcleByTemplate(params, pojoClass, dataSet,            map);
}
/**
* 导出⽂件通过模板解析只有模板,没有集合
*
* @param params
*            导出参数类
* @param map
*            模板集合
* @return
*/
public static Workbook exportExcel(TemplateExportParams params, Map<String, Object> map) {        return new ExcelExportOfTemplateUtil().createExcleByTemplate(params, null, null, map);
}
/**
* 导出⽂件通过模板解析只有模板,没有集合
* 每个sheet对应⼀个map,导出到处,key是sheet的NUM
* @param params
*            导出参数类
* @param map
*            模板集合
* @return
*/
public static Workbook exportExcel(Map<Integer, Map<String, Object>> map,
TemplateExportParams params) {
return new ExcelExportOfTemplateUtil().createExcleByTemplate(params, map);
}
人力资源资格考试
}
2 对象实体类
/**
* Copyright 2013-2015 JueYue (qrb.)
*
*
*  Licend under the Apache Licen, Version 2.0 (the "Licen");
*  you may not u this file except in compliance with the Licen.
*  You may obtain a copy of the Licen at
*
*    www.apache/licens/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
* distributed under the Licen is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licen for the specific language governing permissions and
* limitations under the Licen.
*/
package cn.l.entity.params;
import java.util.List;
/**
* excel 导出⼯具类,对cell类型做映射
*
* @author JueYue
* @version 1.0 2013年8⽉24⽇
*/
public class ExcelExportEntity extends ExcelBaEntity implements Comparable<ExcelExportEntity> {    public ExcelExportEntity() {
matt
}
public ExcelExportEntity(String name) {
super.name = name;
}
public ExcelExportEntity(String name, Object key) {
super.name = name;
this.key = key;
}
public ExcelExportEntity(String name, Object key, int width) {
super.name = name;
this.width = width;
this.key = key;
}
/**
* 如果是MAP导出,这个是map的key
*/
private Object                  key;
private double                  width          = 10;
private double                  height          = 10;
/**
* 图⽚的类型,1是⽂件,2是数据库
*/
private int                    exportImageType = 0;
/**
* 排序顺序
*/
private int                    orderNum        = 0;
/**
* 是否⽀持换⾏
* 是否⽀持换⾏
*/
private boolean                isWrap;
/**
* 是否需要合并
*/
private boolean                needMerge;德语发音规则
/**
* 单元格纵向合并
hobbyshanghai*/
private boolean                mergeVertical;
/
**
* 合并依赖`
*/
private int[]                  mergeRely;
/**
* 后缀
*/
private String                  suffix;
/**
* 统计
*/
private boolean                isStatistics;
private String                  numFormat;
/**
*  是否隐藏列
*/
private boolean                isColumnHidden;
/**
* 枚举导出属性字段
*/
private String                  enumExportField;
private List<ExcelExportEntity> list;
public int getExportImageType() {
return exportImageType;
}
public double getHeight() {
return height;
}
public Object getKey() {
return key;
}
public List<ExcelExportEntity> getList() {
return list;
}
public int[] getMergeRely() {
return mergeRely == null ? new int[0] : mergeRely;    }
public int getOrderNum() {
return orderNum;
}
public double getWidth() {
return width;
}
public boolean isMergeVertical() {

本文发布于:2023-07-03 09:27:27,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/1075809.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:模板   是否   对象   合并   对应   表格   导出   数据
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图