`

dq2

    博客分类:
  • dq
dq 
阅读更多
/**
     * excel读取数据对WebUserBean设值封装
     * @author : zhouyao
     * @version: 1.0
     * <p>时间 : 2011-9-27</p>
     * <p>描述 : excel读取数据对WebUserBean设值封装</p>
     * <p>Copyright 1988-2005, Huawei Tech. Co., Ltd.</p>
     * @param excelHeader 表头
     * @param cells 每列数据  
     * @param webUserBean web账号bean
     */
    private void readExcelWebUserArray(Map<Integer, String> excelHeader,
            Iterator<Cell> cells, WebUserBean webUserBean,
            HttpServletRequest request)
    {
        HSSFCell cell = (HSSFCell) cells.next();
        String isKey = excelHeader.get(cell.getColumnIndex());
        if (isKey != null)
        {
            String cellValue = "";
            switch (cell.getCellType())
            {
                case Cell.CELL_TYPE_NUMERIC:
                    //值为数字类型(int或double、float)以double读取转换String
                    cellValue = String.valueOf(cell.getNumericCellValue());
                    cellValue = cellValue.substring(0, cellValue.length() - 2);
                    break;
                case Cell.CELL_TYPE_FORMULA:
                    cellValue = cell.getCellFormula();
                    break;
                default:
                    cellValue = cell.getStringCellValue();
                    break;
            }
            if (!"".equals(cellValue))
            {
                String language = (String) request.getSession().getAttribute(
                        "language");
                if ("zh_CN".equals(language))
                {
                    if (REGIN_user_name.equals(isKey))
                    {
                        webUserBean.setUsername(cellValue);
                    }
                    else if (REGIN_serviceDomain.equals(isKey))
                    {
                        webUserBean.setServiceDomain(cellValue);
                    }
                    else if (REGIN_proxyServer.equals(isKey))
                    {
                        webUserBean.setProxyServer(cellValue);
                    }
                    else if (REGIN_authorizedName.equals(isKey))
                    {
                        webUserBean.setAuthorizedName(cellValue);
                    }
                    else if (REGIN_password.equals(isKey))
                    {
                        webUserBean.setPassword(cellValue);
                    }
                }
                else
                {
                    //英文格式
                    if (EN_user_name.equals(isKey))
                    {
                        webUserBean.setUsername(cellValue);
                    }
                    else if (EN_serviceDomain.equals(isKey))
                    {
                        webUserBean.setServiceDomain(cellValue);
                    }
                    else if (EN_proxyServer.equals(isKey))
                    {
                        webUserBean.setProxyServer(cellValue);
                    }
                    else if (EN_authorizedName.equals(isKey))
                    {
                        webUserBean.setAuthorizedName(cellValue);
                    }
                    else if (EN_password.equals(isKey))
                    {
                        webUserBean.setPassword(cellValue);
                    }
                }
            }
        }
    }
分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics