當前位置: 首頁>>代碼示例>>Java>>正文


Java ExcelImportException類代碼示例

本文整理匯總了Java中org.jeecgframework.poi.exception.excel.ExcelImportException的典型用法代碼示例。如果您正苦於以下問題:Java ExcelImportException類的具體用法?Java ExcelImportException怎麽用?Java ExcelImportException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ExcelImportException類屬於org.jeecgframework.poi.exception.excel包,在下文中一共展示了ExcelImportException類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readExcel

import org.jeecgframework.poi.exception.excel.ExcelImportException; //導入依賴的package包/類
private <T> List<T> readExcel(OPCPackage opcPackage, Class<?> pojoClass, ImportParams params,
                              ISaxRowRead rowRead, IExcelReadRowHanlder hanlder) {
    try {
        XSSFReader xssfReader = new XSSFReader(opcPackage);
        SharedStringsTable sst = xssfReader.getSharedStringsTable();
        if (rowRead == null) {
            rowRead = new SaxRowRead(pojoClass, params, hanlder);
        }
        XMLReader parser = fetchSheetParser(sst, rowRead);
        Iterator<InputStream> sheets = xssfReader.getSheetsData();
        int sheetIndex = 0;
        while (sheets.hasNext() && sheetIndex < params.getSheetNum()) {
            sheetIndex++;
            InputStream sheet = sheets.next();
            InputSource sheetSource = new InputSource(sheet);
            parser.parse(sheetSource);
            sheet.close();
        }
        return rowRead.getList();
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new ExcelImportException("SAX導入數據失敗");
    }
}
 
開發者ID:rushingpig,項目名稱:poix,代碼行數:25,代碼來源:SaxReadExcel.java

示例2: parse

import org.jeecgframework.poi.exception.excel.ExcelImportException; //導入依賴的package包/類
@Override
public void parse(int index, List<SaxReadCellEntity> datas) {
    try {
        if (datas == null || datas.size() == 0) {
            return;
        }
        //標題行跳過
        if (index < params.getTitleRows()) {
            return;
        }
        //表頭行
        if (index < params.getTitleRows() + params.getHeadRows()) {
            addHeadData(datas);
        } else {
            addListData(datas);
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new ExcelImportException(e.getMessage());
    }
}
 
開發者ID:rushingpig,項目名稱:poix,代碼行數:22,代碼來源:SaxRowRead.java

示例3: saveFieldValue

import org.jeecgframework.poi.exception.excel.ExcelImportException; //導入依賴的package包/類
/**
 * 保存字段值(獲取值,校驗值,追加錯誤信息)
 * 
 * @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);
        }
    }
}
 
開發者ID:xiaolanglang,項目名稱:easypoi,代碼行數:37,代碼來源:ExcelImportServer.java

示例4: getDateData

import org.jeecgframework.poi.exception.excel.ExcelImportException; //導入依賴的package包/類
/**
 * 獲取日期類型數據
 * 
 * @author JueYue
 *  2013年11月26日
 * @param entity
 * @param value
 * @return
 */
private Date getDateData(ExcelImportEntity entity, String value) {
    if (StringUtils.isNotEmpty(entity.getFormat()) && StringUtils.isNotEmpty(value)) {
        SimpleDateFormat format = new SimpleDateFormat(entity.getFormat());
        try {
            return format.parse(value);
        } catch (ParseException e) {
            LOGGER.error("時間格式化失敗,格式化:{},值:{}", entity.getFormat(), value);
            throw new ExcelImportException(ExcelImportEnum.GET_VALUE_ERROR);
        }
    }
    return null;
}
 
開發者ID:rushingpig,項目名稱:poix,代碼行數:22,代碼來源:CellValueServer.java

示例5: initParams

import org.jeecgframework.poi.exception.excel.ExcelImportException; //導入依賴的package包/類
private void initParams(Class<?> pojoClass, ImportParams params) {
    try {

        Field fileds[] = PoiPublicUtil.getClassFields(pojoClass);
        ExcelTarget etarget = pojoClass.getAnnotation(ExcelTarget.class);
        if (etarget != null) {
            targetId = etarget.value();
        }
        getAllExcelField(targetId, fileds, excelParams, excelCollection, pojoClass, null);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new ExcelImportException(e.getMessage());
    }

}
 
開發者ID:rushingpig,項目名稱:poix,代碼行數:16,代碼來源:SaxRowRead.java

示例6: getDateData

import org.jeecgframework.poi.exception.excel.ExcelImportException; //導入依賴的package包/類
/**
 * 獲取日期類型數據
 * 
 * @Author JueYue
 * @date 2013年11月26日
 * @param entity
 * @param value
 * @return
 */
private Date getDateData(ExcelImportEntity entity, String value) {
    if (StringUtils.isNotEmpty(entity.getFormat()) && StringUtils.isNotEmpty(value)) {
        SimpleDateFormat format = new SimpleDateFormat(entity.getFormat());
        try {
            return format.parse(value);
        } catch (ParseException e) {
            LOGGER.error("時間格式化失敗,格式化:{},值:{}", entity.getFormat(), value);
            throw new ExcelImportException(ExcelImportEnum.GET_VALUE_ERROR);
        }
    }
    return null;
}
 
開發者ID:xiaolanglang,項目名稱:easypoi,代碼行數:22,代碼來源:CellValueServer.java

示例7: getValueByType

import org.jeecgframework.poi.exception.excel.ExcelImportException; //導入依賴的package包/類
/**
 * 根據返回類型獲取返回值
 * 
 * @param xclass
 * @param result
 * @param entity 
 * @return
 */
private Object getValueByType(String xclass, Object result, ExcelImportEntity entity) {
    try {
        if ("class java.util.Date".equals(xclass)) {
            return result;
        }
        if ("class java.lang.Boolean".equals(xclass) || "boolean".equals(xclass)) {
            return Boolean.valueOf(String.valueOf(result));
        }
        if ("class java.lang.Double".equals(xclass) || "double".equals(xclass)) {
            return Double.valueOf(String.valueOf(result));
        }
        if ("class java.lang.Long".equals(xclass) || "long".equals(xclass)) {
            return Long.valueOf(String.valueOf(result));
        }
        if ("class java.lang.Float".equals(xclass) || "float".equals(xclass)) {
            return Float.valueOf(String.valueOf(result));
        }
        if ("class java.lang.Integer".equals(xclass) || "int".equals(xclass)) {
            return Integer.valueOf(String.valueOf(result));
        }
        if ("class java.math.BigDecimal".equals(xclass)) {
            return new BigDecimal(String.valueOf(result));
        }
        if ("class java.lang.String".equals(xclass)) {
            //針對String 類型,但是Excel獲取的數據卻不是String,比如Double類型,防止科學計數法
            if (result instanceof String) {
                return result;
            }
            // double類型防止科學計數法
            if (result instanceof Double) {
                return PoiPublicUtil.doubleToString((Double) result);
            }
            return String.valueOf(result);
        }
        return result;
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new ExcelImportException(ExcelImportEnum.GET_VALUE_ERROR);
    }
}
 
開發者ID:xiaolanglang,項目名稱:easypoi,代碼行數:49,代碼來源:CellValueServer.java


注:本文中的org.jeecgframework.poi.exception.excel.ExcelImportException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。