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() {