Java Code Examples for org.jeecgframework.poi.excel.entity.ImportParams#getDataHanlder()

The following examples show how to use org.jeecgframework.poi.excel.entity.ImportParams#getDataHanlder() . 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: ExcelImportServer.java    From autopoi with Apache License 2.0 6 votes vote down vote up
/**
 * 保存字段值(获取值,校验值,追加错误信息)
 * 
 * @param params
 * @param object
 * @param cell
 * @param excelParams
 * @param titleString
 * @param row
 * @throws Exception
 */
private void saveFieldValue(ImportParams params, Object object, Cell cell, Map<String, ExcelImportEntity> excelParams, String titleString, Row row) throws Exception {
	Object value = cellValueServer.getValue(params.getDataHanlder(), object, cell, excelParams, titleString);
	if (object instanceof Map) {
		if (params.getDataHanlder() != null) {
			params.getDataHanlder().setMapValue((Map) object, titleString, value);
		} else {
			((Map) object).put(titleString, value);
		}
	} else {
		ExcelVerifyHanlderResult verifyResult = verifyHandlerServer.verifyData(object, value, titleString, excelParams.get(titleString).getVerify(), params.getVerifyHanlder());
		if (verifyResult.isSuccess()) {
			setValues(excelParams.get(titleString), object, value);
		} else {
			Cell errorCell = row.createCell(row.getLastCellNum());
			errorCell.setCellValue(verifyResult.getMsg());
			errorCell.setCellStyle(errorCellStyle);
			verfiyFail = true;
			throw new ExcelImportException(ExcelImportEnum.VERIFY_ERROR);
		}
	}
}
 
Example 2
Source File: ExcelImportServer.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 保存字段值(获取值,校验值,追加错误信息)
 * 
 * @param params
 * @param object
 * @param cell
 * @param excelParams
 * @param titleString
 * @param row
 * @throws Exception
 */
private void saveFieldValue(ImportParams params, Object object, Cell cell, Map<String, ExcelImportEntity> excelParams, String titleString, Row row) throws Exception {
	Object value = cellValueServer.getValue(params.getDataHanlder(), object, cell, excelParams, titleString);
	if (object instanceof Map) {
		if (params.getDataHanlder() != null) {
			params.getDataHanlder().setMapValue((Map) object, titleString, value);
		} else {
			((Map) object).put(titleString, value);
		}
	} else {
		ExcelVerifyHanlderResult verifyResult = verifyHandlerServer.verifyData(object, value, titleString, excelParams.get(titleString).getVerify(), params.getVerifyHanlder());
		if (verifyResult.isSuccess()) {
			setValues(excelParams.get(titleString), object, value);
		} else {
			Cell errorCell = row.createCell(row.getLastCellNum());
			errorCell.setCellValue(verifyResult.getMsg());
			errorCell.setCellStyle(errorCellStyle);
			verfiyFail = true;
			throw new ExcelImportException(ExcelImportEnum.VERIFY_ERROR);
		}
	}
}
 
Example 3
Source File: ExcelImportServer.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 保存字段值(获取值,校验值,追加错误信息)
 * 
 * @param params
 * @param object
 * @param cell
 * @param excelParams
 * @param titleString
 * @param row
 * @throws Exception
 */
private void saveFieldValue(ImportParams params, Object object, Cell cell,
                            Map<String, ExcelImportEntity> excelParams, String titleString,
                            Row row) throws Exception {
    Object value = cellValueServer.getValue(params.getDataHanlder(), object, cell, excelParams,
        titleString);
    if (object instanceof Map) {
        if (params.getDataHanlder() != null) {
            params.getDataHanlder().setMapValue((Map) object, titleString, value);
        } else {
            ((Map) object).put(titleString, value);
        }
    } else {
        ExcelVerifyHanlderResult verifyResult = verifyHandlerServer.verifyData(object, value,
            titleString, excelParams.get(titleString).getVerify(), params.getVerifyHanlder());
        if (verifyResult.isSuccess()) {
            setValues(excelParams.get(titleString), object, value);
        } else {
            Cell errorCell = row.createCell(row.getLastCellNum());
            errorCell.setCellValue(verifyResult.getMsg());
            errorCell.setCellStyle(errorCellStyle);
            verfiyFail = true;
            throw new ExcelImportException(ExcelImportEnum.VERIFY_ERROR);
        }
    }
}