org.jeecgframework.poi.exception.excel.enums.ExcelExportEnum Java Examples

The following examples show how to use org.jeecgframework.poi.exception.excel.enums.ExcelExportEnum. 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: ExcelExportOfTemplateUtil.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
public Workbook createExcleByTemplate(TemplateExportParams params, Class<?> pojoClass, Collection<?> dataSet, Map<String, Object> map) {
	// step 1. 判断模板的地址
	if (params == null || map == null || StringUtils.isEmpty(params.getTemplateUrl())) {
		throw new ExcelExportException(ExcelExportEnum.PARAMETER_ERROR);
	}
	Workbook wb = null;
	// step 2. 判断模板的Excel类型,解析模板
	try {
		this.teplateParams = params;
		wb = getCloneWorkBook();
		// 创建表格样式
		setExcelExportStyler((IExcelExportStyler) teplateParams.getStyle().getConstructor(Workbook.class).newInstance(wb));
		// step 3. 解析模板
		for (int i = 0, le = params.isScanAllsheet() ? wb.getNumberOfSheets() : params.getSheetNum().length; i < le; i++) {
			if (params.getSheetName() != null && params.getSheetName().length > i && StringUtils.isNotEmpty(params.getSheetName()[i])) {
				wb.setSheetName(i, params.getSheetName()[i]);
			}
			tempCreateCellSet.clear();
			parseTemplate(wb.getSheetAt(i), map);
		}
		if (dataSet != null) {
			// step 4. 正常的数据填充
			dataHanlder = params.getDataHanlder();
			if (dataHanlder != null) {
				needHanlderList = Arrays.asList(dataHanlder.getNeedHandlerFields());
			}
			addDataToSheet(pojoClass, dataSet, wb.getSheetAt(params.getDataSheetNum()), wb);
		}
	} catch (Exception e) {
		LOGGER.error(e.getMessage(), e);
		return null;
	}
	return wb;
}
 
Example #2
Source File: ExcelExportOfTemplateUtil.java    From easypoi with Apache License 2.0 5 votes vote down vote up
public Workbook createExcleByTemplate(TemplateExportParams params, Class<?> pojoClass,
                                      Collection<?> dataSet, Map<String, Object> map) {
    // step 1. 判断模板的地址
    if (params == null || map == null || StringUtils.isEmpty(params.getTemplateUrl())) {
        throw new ExcelExportException(ExcelExportEnum.PARAMETER_ERROR);
    }
    Workbook wb = null;
    // step 2. 判断模板的Excel类型,解析模板
    try {
        this.teplateParams = params;
        wb = getCloneWorkBook();
        // 创建表格样式
        setExcelExportStyler((IExcelExportStyler) teplateParams.getStyle()
            .getConstructor(Workbook.class).newInstance(wb));
        // step 3. 解析模板
        for (int i = 0, le = params.isScanAllsheet() ? wb.getNumberOfSheets() : params
            .getSheetNum().length; i < le; i++) {
            if (params.getSheetName() != null && params.getSheetName().length > i
                && StringUtils.isNotEmpty(params.getSheetName()[i])) {
                wb.setSheetName(i, params.getSheetName()[i]);
            }
            tempCreateCellSet.clear();
            parseTemplate(wb.getSheetAt(i), map);
        }
        if (dataSet != null) {
            // step 4. 正常的数据填充
            dataHanlder = params.getDataHanlder();
            if (dataHanlder != null) {
                needHanlderList = Arrays.asList(dataHanlder.getNeedHandlerFields());
            }
            addDataToSheet(pojoClass, dataSet, wb.getSheetAt(params.getDataSheetNum()), wb);
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        return null;
    }
    return wb;
}
 
Example #3
Source File: ExcelExportOfTemplateUtil.java    From autopoi with Apache License 2.0 5 votes vote down vote up
public Workbook createExcleByTemplate(TemplateExportParams params, Class<?> pojoClass, Collection<?> dataSet, Map<String, Object> map) {
	// step 1. 判断模板的地址
	if (params == null || map == null || StringUtils.isEmpty(params.getTemplateUrl())) {
		throw new ExcelExportException(ExcelExportEnum.PARAMETER_ERROR);
	}
	Workbook wb = null;
	// step 2. 判断模板的Excel类型,解析模板
	try {
		this.teplateParams = params;
		wb = getCloneWorkBook();
		// 创建表格样式
		setExcelExportStyler((IExcelExportStyler) teplateParams.getStyle().getConstructor(Workbook.class).newInstance(wb));
		// step 3. 解析模板
		for (int i = 0, le = params.isScanAllsheet() ? wb.getNumberOfSheets() : params.getSheetNum().length; i < le; i++) {
			if (params.getSheetName() != null && params.getSheetName().length > i && StringUtils.isNotEmpty(params.getSheetName()[i])) {
				wb.setSheetName(i, params.getSheetName()[i]);
			}
			tempCreateCellSet.clear();
			parseTemplate(wb.getSheetAt(i), map);
		}
		if (dataSet != null) {
			// step 4. 正常的数据填充
			dataHanlder = params.getDataHanlder();
			if (dataHanlder != null) {
				needHanlderList = Arrays.asList(dataHanlder.getNeedHandlerFields());
			}
			addDataToSheet(pojoClass, dataSet, wb.getSheetAt(params.getDataSheetNum()), wb);
		}
	} catch (Exception e) {
		LOGGER.error(e.getMessage(), e);
		return null;
	}
	return wb;
}
 
Example #4
Source File: ExcelExportException.java    From jeasypoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportException(String message, ExcelExportEnum type) {
	super(message);
	this.type = type;
}
 
Example #5
Source File: ExcelExportException.java    From easypoi with Apache License 2.0 4 votes vote down vote up
public void setType(ExcelExportEnum type) {
    this.type = type;
}
 
Example #6
Source File: ExcelExportException.java    From easypoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportEnum getType() {
    return type;
}
 
Example #7
Source File: ExcelExportException.java    From easypoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportException(String message, ExcelExportEnum type) {
    super(message);
    this.type = type;
}
 
Example #8
Source File: ExcelExportException.java    From easypoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportException(ExcelExportEnum type, Throwable cause) {
    super(type.getMsg(), cause);
}
 
Example #9
Source File: ExcelExportException.java    From easypoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportException(ExcelExportEnum type) {
    super(type.getMsg());
    this.type = type;
}
 
Example #10
Source File: ExcelExportException.java    From jeasypoi with Apache License 2.0 4 votes vote down vote up
public void setType(ExcelExportEnum type) {
	this.type = type;
}
 
Example #11
Source File: ExcelExportException.java    From jeasypoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportEnum getType() {
	return type;
}
 
Example #12
Source File: ExcelExportException.java    From jeasypoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportException(ExcelExportEnum type, Throwable cause) {
	super(type.getMsg(), cause);
}
 
Example #13
Source File: ExcelExportException.java    From jeasypoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportException(ExcelExportEnum type) {
	super(type.getMsg());
	this.type = type;
}
 
Example #14
Source File: ExcelExportException.java    From autopoi with Apache License 2.0 4 votes vote down vote up
public void setType(ExcelExportEnum type) {
	this.type = type;
}
 
Example #15
Source File: ExcelExportException.java    From autopoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportEnum getType() {
	return type;
}
 
Example #16
Source File: ExcelExportException.java    From autopoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportException(String message, ExcelExportEnum type) {
	super(message);
	this.type = type;
}
 
Example #17
Source File: ExcelExportException.java    From autopoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportException(ExcelExportEnum type, Throwable cause) {
	super(type.getMsg(), cause);
}
 
Example #18
Source File: ExcelExportException.java    From autopoi with Apache License 2.0 4 votes vote down vote up
public ExcelExportException(ExcelExportEnum type) {
	super(type.getMsg());
	this.type = type;
}