Java Code Examples for org.jeecgframework.poi.excel.entity.params.ExcelExportEntity#setWidth()

The following examples show how to use org.jeecgframework.poi.excel.entity.params.ExcelExportEntity#setWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExportBase.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 注解到导出对象的转换
 * 
 * @param targetId
 * @param field
 * @param excelEntity
 * @param excel
 * @param pojoClass
 * @throws Exception
 */
private void getExcelField(String targetId, Field field, ExcelExportEntity excelEntity,
                           Excel excel, Class<?> pojoClass) throws Exception {
    excelEntity.setName(getExcelName(excel.name(), targetId));
    excelEntity.setWidth(excel.width());
    excelEntity.setHeight(excel.height());
    excelEntity.setNeedMerge(excel.needMerge());
    excelEntity.setMergeVertical(excel.mergeVertical());
    excelEntity.setMergeRely(excel.mergeRely());
    excelEntity.setReplace(excel.replace());
    excelEntity.setOrderNum(getCellOrder(excel.orderNum(), targetId));
    excelEntity.setWrap(excel.isWrap());
    excelEntity.setExportImageType(excel.imageType());
    excelEntity.setSuffix(excel.suffix());
    excelEntity.setDatabaseFormat(excel.databaseFormat());
    excelEntity.setFormat(StringUtils.isNotEmpty(excel.exportFormat()) ? excel.exportFormat()
        : excel.format());
    excelEntity.setStatistics(excel.isStatistics());
    String fieldname = field.getName();
    excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass));
}
 
Example 2
Source File: ExcelTempletController.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
 * 把基础数据转换成Excel导出的数据
 *
 * @param lists
 * @return
 */
private List<ExcelExportEntity> convertToExportEntity(List<CgFormFieldEntity> lists) {
	// 对字段列按顺序排序
	Collections.sort(lists, new FieldNumComparator());
	List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();
	for (int i = 0; i < lists.size(); i++) {
		if (lists.get(i).getIsShow().equals("Y")) {
			ExcelExportEntity entity = new ExcelExportEntity(lists.get(i).getContent(), lists.get(i).getFieldName());
			int columnWidth = lists.get(i).getLength() == 0 ? 12 : lists.get(i).getLength() > 30 ? 30 : lists.get(i).getLength();
			if (lists.get(i).getShowType().equals("date")) {
				entity.setFormat("yyyy-MM-dd");
			} else if (lists.get(i).getShowType().equals("datetime")) {
				entity.setFormat("yyyy-MM-dd HH:mm:ss");
			}
			entity.setWidth(columnWidth);
			entityList.add(entity);
		}
	}
	return entityList;
}
 
Example 3
Source File: ExcelExportServer.java    From autopoi with Apache License 2.0 5 votes vote down vote up
private ExcelExportEntity indexExcelEntity(ExportParams entity) {
	ExcelExportEntity exportEntity = new ExcelExportEntity();
	exportEntity.setOrderNum(0);
	exportEntity.setName(entity.getIndexName());
	exportEntity.setWidth(10);
	exportEntity.setFormat(PoiBaseConstants.IS_ADD_INDEX);
	return exportEntity;
}
 
Example 4
Source File: ExportBase.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 注解到导出对象的转换
 * 
 * @param targetId
 * @param field
 * @param excelEntity
 * @param excel
 * @param pojoClass
 * @throws Exception
 */
private void getExcelField(String targetId, Field field, ExcelExportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception {
	excelEntity.setName(getExcelName(excel.name(), targetId));
	excelEntity.setWidth(excel.width());
	excelEntity.setHeight(excel.height());
	excelEntity.setNeedMerge(excel.needMerge());
	excelEntity.setMergeVertical(excel.mergeVertical());
	excelEntity.setMergeRely(excel.mergeRely());
	excelEntity.setReplace(excel.replace());
	if(StringUtils.isNotEmpty(excel.dicCode())){
		EasypoiDictServiceI jeecgDictService = null;
		try {
			jeecgDictService = ApplicationContextUtil.getContext().getBean(EasypoiDictServiceI.class);
		} catch (Exception e) {
		}
		if(jeecgDictService!=null){
			 String[] dictReplace = jeecgDictService.queryDict(excel.dictTable(), excel.dicCode(), excel.dicText());
			 if(excelEntity.getReplace()!=null && dictReplace!=null && dictReplace.length!=0){
				 excelEntity.setReplace(dictReplace);
			 }
		}
	}
	excelEntity.setOrderNum(getCellOrder(excel.orderNum(), targetId));
	excelEntity.setWrap(excel.isWrap());
	excelEntity.setExportImageType(excel.imageType());
	excelEntity.setSuffix(excel.suffix());
	excelEntity.setDatabaseFormat(excel.databaseFormat());
	excelEntity.setFormat(StringUtils.isNotEmpty(excel.exportFormat()) ? excel.exportFormat() : excel.format());
	excelEntity.setStatistics(excel.isStatistics());
	String fieldname = field.getName();
	excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass));
}
 
Example 5
Source File: ExcelExportServer.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
private ExcelExportEntity indexExcelEntity(ExportParams entity) {
	ExcelExportEntity exportEntity = new ExcelExportEntity();
	exportEntity.setOrderNum(0);
	exportEntity.setName(entity.getIndexName());
	exportEntity.setWidth(10);
	exportEntity.setFormat(PoiBaseConstants.IS_ADD_INDEX);
	return exportEntity;
}
 
Example 6
Source File: ExcelExportServer.java    From easypoi with Apache License 2.0 5 votes vote down vote up
private ExcelExportEntity indexExcelEntity(ExportParams entity) {
    ExcelExportEntity exportEntity = new ExcelExportEntity();
    exportEntity.setOrderNum(0);
    exportEntity.setName(entity.getIndexName());
    exportEntity.setWidth(10);
    exportEntity.setFormat(PoiBaseConstants.IS_ADD_INDEX);
    return exportEntity;
}
 
Example 7
Source File: ExportBase.java    From autopoi with Apache License 2.0 4 votes vote down vote up
/**
 * 注解到导出对象的转换
 * 
 * @param targetId
 * @param field
 * @param excelEntity
 * @param excel
 * @param pojoClass
 * @throws Exception
 */
private void getExcelField(String targetId, Field field, ExcelExportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception {
	excelEntity.setName(getExcelName(excel.name(), targetId));
	excelEntity.setWidth(excel.width());
	excelEntity.setHeight(excel.height());
	excelEntity.setNeedMerge(excel.needMerge());
	excelEntity.setMergeVertical(excel.mergeVertical());
	excelEntity.setMergeRely(excel.mergeRely());
	excelEntity.setReplace(excel.replace());
	if(StringUtils.isNotEmpty(excel.dicCode())){
		AutoPoiDictServiceI jeecgDictService = null;
		try {
			jeecgDictService = ApplicationContextUtil.getContext().getBean(AutoPoiDictServiceI.class);
		} catch (Exception e) {
		}
		if(jeecgDictService!=null){
			 String[] dictReplace = jeecgDictService.queryDict(excel.dictTable(), excel.dicCode(), excel.dicText());
			 if(excelEntity.getReplace()!=null && dictReplace!=null && dictReplace.length!=0){
				 excelEntity.setReplace(dictReplace);
			 }
		}
	}
	excelEntity.setOrderNum(getCellOrder(excel.orderNum(), targetId));
	excelEntity.setWrap(excel.isWrap());
	excelEntity.setExportImageType(excel.imageType());
	excelEntity.setSuffix(excel.suffix());
	excelEntity.setDatabaseFormat(excel.databaseFormat());
	excelEntity.setFormat(StringUtils.isNotEmpty(excel.exportFormat()) ? excel.exportFormat() : excel.format());
	excelEntity.setStatistics(excel.isStatistics());
	String fieldname = field.getName();
	//update-begin-author:taoyan date:20200319 for:autopoi 双表头问题 #862 基于注解的解决方案
	excelEntity.setKey(fieldname);
	//update-end-author:taoyan date:20200319 for:autopoi 双表头问题 #862 基于注解的解决方案
	//update-begin-author:taoyan date:20200319 for:Excel注解的numFormat方法似乎未实现 #970
	excelEntity.setNumFormat(excel.numFormat());
	//update-end-author:taoyan date:20200319 for:Excel注解的numFormat方法似乎未实现 #970
	//update-begin-author:taoyan date:20180615 for:TASK #2798 【例子】导入扩展方法,支持自定义导入字段转换规则
	excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass,excel.exportConvert()));
	//update-end-author:taoyan date:20180615 for:TASK #2798 【例子】导入扩展方法,支持自定义导入字段转换规则
	//update-begin-author:taoyan date:20180801 for:TASK #3038 【bug】Excel 导出多个值(逗号隔开的情况下,导出字典值是ID值)
	excelEntity.setMultiReplace(excel.multiReplace());
	//update-end-author:taoyan date:20180801 for:TASK #3038 【bug】Excel 导出多个值(逗号隔开的情况下,导出字典值是ID值)
	//update-begin-author:taoyan date:20200319 for:autopoi 双表头问题 #862 基于实体注解的解决方案
	if(StringUtils.isNotEmpty(excel.groupName())){
		excelEntity.setGroupName(excel.groupName());
		excelEntity.setColspan(true);
	}
	//update-end-author:taoyan date:20200319 for:autopoi 双表头问题 #862 基于实体注解的解决方案
}