Example usage for org.apache.poi.ss.usermodel Row cellIterator

List of usage examples for org.apache.poi.ss.usermodel Row cellIterator

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Row cellIterator.

Prototype

Iterator<Cell> cellIterator();

Source Link

Usage

From source file:com.fota.devMgt.controller.DevOpenMgtCTR.java

License:Open Source License

/**
 *  ?  , ? ?   ./*  ww  w .j  a va 2  s . co  m*/
 * ?  ?.
 * @param vo
 * @param model
 * @return
 */
@RequestMapping(value = "/openInfoUpload")
public ModelAndView uploadTest(HttpServletRequest request, HttpServletResponse response,
        @ModelAttribute("devSearchVO") DevSearchVO vo, ModelMap model) throws Exception {
    if (!request.getServletPath().equals("/commonDevice/devMgt/openInfoUpload")) {
        response.setStatus(403);
        return null;
    }
    //   ? ?
    String path = "/jb_log/excelUpload/devOpenInfoFiles_tmp/";
    File pysicalFolder = new File(path);
    if (!pysicalFolder.exists() || !pysicalFolder.isDirectory()) {
        pysicalFolder.mkdirs();
    }

    //  ?
    MultipartRequest multi = new MultipartRequest(request, path, 10 * 1024 * 1024, "utf-8");
    String upFile = multi.getFilesystemName("file");

    if (upFile == null || upFile.equals("")) {
        model.addAttribute("msg", "?? .");
        return new ModelAndView(ajaxMainView, model);
    }

    // poi    ? ? ?
    File upfile = new File(path + upFile);

    // poi 
    try {
        FileInputStream file = new FileInputStream(upfile);

        //.xlsx file
        XSSFWorkbook workbook = new XSSFWorkbook(file);

        // 
        XSSFSheet sheet = workbook.getSheetAt(0);

        //  
        Iterator<Row> rowIterator = sheet.iterator();

        //    ?? 
        List<DevSearchVO> rs = new ArrayList();

        // ? 
        rowIterator.next();

        while (rowIterator.hasNext()) {
            Row row = rowIterator.next();
            //For each row, iterate through all the columns
            Iterator<Cell> cellIterator = row.cellIterator();

            DevSearchVO tmp = new DevSearchVO();
            rs.add(tmp);

            // 
            Cell cell = row.getCell(0);
            tmp.setBizNm(cell.toString().trim());
            if (tmp.getBizNm().length() > 50) {
                tmp.setBizNm(tmp.getBizNm().substring(0, 49)); // ? 
            }

            // 
            cell = row.getCell(1);
            tmp.setSvcNm(cell.toString().trim());
            if (tmp.getSvcNm().length() > 50) {
                tmp.setSvcNm(tmp.getSvcNm().substring(0, 49)); // ? 
            }

            // ??
            cell = row.getCell(2);
            tmp.setDevModelNm(cell.toString().trim());
            if (tmp.getDevModelNm().length() > 50) {
                tmp.setDevModelNm(tmp.getDevModelNm().substring(0, 49)); // ? 
            }

            // CTN
            cell = row.getCell(3);
            tmp.setCtn(cell.toString().trim());
            if (tmp.getCtn().length() > 20) {
                tmp.setCtn(tmp.getCtn().substring(0, 19)); // ? 
            }

            // 
            cell = row.getCell(4);
            tmp.setDealerNm(cell.toString().trim());
            if (tmp.getDealerNm().length() > 50) {
                tmp.setDealerNm(tmp.getDealerNm().substring(0, 49)); // ? 
            }

            //  
            cell = row.getCell(5, row.CREATE_NULL_AS_BLANK);
            tmp.setCustomTag(cell.toString().trim());
            if (tmp.getCustomTag().length() > 30) {
                tmp.setCustomTag(tmp.getCustomTag().substring(0, 29)); // ? 
            }

            // ? ?? 
            cell = row.getCell(6, row.CREATE_NULL_AS_BLANK);
            tmp.setApprovalYn(cell.toString().trim());
            if (tmp.getApprovalYn().equals(""))
                tmp.setApprovalYn("Y");
            if (!tmp.getApprovalYn().equals("Y"))
                tmp.setApprovalYn("N");

            tmp.setMemo("");
        }

        for (DevSearchVO tmp : rs) {
            mySVC.addDevInfo(tmp);
        }

        DevSearchVO footer = new DevSearchVO();
        rs.add(footer);

        file.close();
        upfile.delete();

        DevSearchVO tempVo;
        // -  ? java-Ctrl ?  - DMS ?
        if (rs != null && rs.size() > 0) {
            for (int i = 0; i < rs.size(); i++) {
                tempVo = rs.get(i);
                if (tempVo.getCtn() != null && !tempVo.getCtn().isEmpty()) {
                    tempVo.setCtn(Masking.convertCtn(tempVo.getCtn()));
                }
            }
        }

        model.addAttribute("gridData", rs);
    } catch (Exception e) {
        e.printStackTrace();
        upfile.delete();
        model.addAttribute("msg", "?? ?   .");
    }

    return new ModelAndView(ajaxMainView, model);
}

From source file:com.fota.fota3g.deviceMgt.controller.TargetGroupMgtCTR.java

License:Open Source License

/**
 * targetGroup insert - Excel//from  ww  w .j  a va 2s .c o  m
 * @param param
 * @param response
 * @return
 */
@RequestMapping(value = "/addTargetGroupExcel")
@ResponseBody
public ModelAndView addTargetGroupExcel(HttpServletRequest request, HttpServletResponse response,
        ModelMap model) throws Exception {
    //      logger.warn(" >>> TargetGroupMgtCTR - addTargetGroupExcel() start... ");

    String retMsg = "";

    //   ? ?
    String path = "/jb_log/excelUpload/targetGroup/";
    File pysicalFolder = new File(path);
    if (!pysicalFolder.exists() || !pysicalFolder.isDirectory()) {
        pysicalFolder.mkdirs();
    }

    //  ?
    MultipartRequest multi = new MultipartRequest(request, path, 10 * 1024 * 1024, "utf-8");
    String upFileName = multi.getFilesystemName("deviceIdF");

    //      logger.warn("path : " + path + " ### name : " + upFileName);

    // user  
    HttpSession httpSession = request.getSession(false);
    UserLoginVO userVo = (UserLoginVO) httpSession.getAttribute("userInfo");
    String userId = userVo.getUserId();

    TargetGroupVo vo = new TargetGroupVo();

    vo.setMoId(userId);
    vo.setListGroupName(multi.getParameter("listGroupName"));
    vo.setDescription(multi.getParameter("description"));
    vo.setDelYN(multi.getParameter("delYN"));
    vo.setDeviceType(multi.getParameter("deviceType"));
    vo.setInputType(multi.getParameter("inputType"));

    //      logger.warn(" >>> TargetGroupMgtCTR - addTargetGroupExcel() vo info\r\n"
    //            + "moId : " + vo.getMoId() + "\r\n"
    //            + "listGroupName : " + vo.getListGroupName() + "\r\n"
    //            + "description : " + vo.getDescription() + "\r\n"
    //            + "delYN : " + vo.getDelYN() + "\r\n"
    //            + "deviceType : " + vo.getDeviceType() + "\r\n"
    //            + "inputType : " + vo.getInputType() + "\r\n"
    //            );

    // poi    ? ? ?
    File upfile = new File(path + upFileName);

    // poi 
    try {
        FileInputStream file = new FileInputStream(upfile);

        //.xlsx file
        XSSFWorkbook workbook = new XSSFWorkbook(file);

        // 
        XSSFSheet sheet = workbook.getSheetAt(0);

        //  
        Iterator<Row> rowIterator = sheet.iterator();

        // ? ? ctn list ?
        List<String> ctnList = new ArrayList<String>();

        // ? 
        //           rowIterator.next();
        String tempCtn = "";
        while (rowIterator.hasNext()) {
            Row row = rowIterator.next();
            //For each row, iterate through all the columns
            Iterator<Cell> cellIterator = row.cellIterator();
            tempCtn = "";

            // ctn
            Cell cell = row.getCell(0);
            tempCtn = cell.toString().trim();
            if (tempCtn != null && !tempCtn.isEmpty()) {
                ctnList.add(tempCtn);
            }
        }

        //           logger.warn("-----------------------------------------------------------------");
        //           for(int i=0; i<ctnList.size(); i++) {
        //              logger.warn("ctnList[" + i + "] : " + ctnList.get(i));
        //           }
        //           logger.warn("-----------------------------------------------------------------");

        // ? (console)   ?
        //  ? ?  '?'   ?? 
        vo.setInputType("console");
        StringBuffer sbTempDevIdC = new StringBuffer();
        for (int i = 0; i < ctnList.size(); i++) {
            sbTempDevIdC.append(ctnList.get(i) + "\n");
        }

        //         logger.warn("ctn str >>>>>\r\n" + sbTempDevIdC.toString());
        vo.setDeviceIdC(sbTempDevIdC.toString());

        vo = targetSVC.insertTargetGroup(vo);
    } catch (Exception e) {
        logger.warn("?? ?   .");
        e.printStackTrace();

        model.addAttribute("msg", "?? ?   .");
    }

    // db  ?  ? 
    upfile.delete();

    return new ModelAndView(ajaxMainView, model);
}

From source file:com.fota.fota3g.selffotaMgt.controller.ListManagementCTR.java

License:Open Source License

/**
 * confirm /*from   w  w w  .  j av  a 2s .  co m*/
 * @param param
 * @param response
 * @return
 */
@RequestMapping(value = "/registListMgt")
@ResponseBody
public ModelAndView registListMgt(HttpServletRequest request, HttpServletResponse response, ModelMap model)
        throws Exception {
    //      logger.warn(" >>>>> Self Fota - ListManagementCTR - registListMgt() start...");

    String retMsg = "-1";

    //   ? ?
    String path = "/jb_log/excelUpload/selfFotaList/";
    File pysicalFolder = new File(path);
    if (!pysicalFolder.exists() || !pysicalFolder.isDirectory()) {
        pysicalFolder.mkdirs();
    }

    //  ?
    MultipartRequest multi = new MultipartRequest(request, path, 10 * 1024 * 1024, "utf-8");
    String upFileName = multi.getFilesystemName("file");

    // ?  ?  
    if (upFileName == null || upFileName.equals("")) {
        model.addAttribute("msg", "?? .");
        return new ModelAndView(ajaxMainView, model);
    }

    // db  Map
    Map<String, String> entity = new HashMap<String, String>();

    // user  
    HttpSession httpSession = request.getSession(false);
    UserLoginVO userVo = (UserLoginVO) httpSession.getAttribute("userInfo");
    String userId = userVo.getUserId();
    //      int devCnt = 0;

    entity.put("reg_id", userId);
    entity.put("file_name", upFileName);
    entity.put("file_path", path); // 3G FOTA src ? path  ? (path + name )
    entity.put("company_name", VoV.replaceRoundBracket(multi.getParameter("maker")));
    //      entity.put("device_cnt", devCnt + "");    // device count  excel file ? count   ?.

    // poi    ? ? ?
    File upfile = new File(path + upFileName);

    List<Map<String, String>> devList = new ArrayList<Map<String, String>>();

    // poi 
    try {
        FileInputStream file = new FileInputStream(upfile);

        //.xlsx file
        XSSFWorkbook workbook = new XSSFWorkbook(file);

        // 
        XSSFSheet sheet = workbook.getSheetAt(0);

        //  
        Iterator<Row> rowIterator = sheet.iterator();

        // ? ? 
        Map<String, String> devInfo = null;

        // ? 
        rowIterator.next();

        while (rowIterator.hasNext()) {
            devInfo = new HashMap<String, String>();

            Row row = rowIterator.next();
            //For each row, iterate through all the columns
            Iterator<Cell> cellIterator = row.cellIterator();

            // model
            Cell cell = row.getCell(0);
            devInfo.put("device_model_name", cell.toString().trim());

            // previous version
            cell = row.getCell(1);
            devInfo.put("device_pre_ver", cell.toString().trim());

            // next version
            cell = row.getCell(2);
            devInfo.put("device_app_ver", cell.toString().trim());

            // ctn
            cell = row.getCell(3);
            devInfo.put("ctn", cell.toString().trim());

            // imei
            cell = row.getCell(4);
            devInfo.put("device_imei", cell.toString().trim());

            devList.add(devInfo);
        }

        entity.put("device_cnt", devList.size() + "");

        //           logger.warn("insertXls data : " + entity.toString());
        int insertRet = listManagementSVC.insertXls(entity);
        //           logger.warn("insertXls ret : " + insertRet);

        String master_idx = "";

        if (insertRet > 0) {
            master_idx = listManagementSVC.getInsertedMasterIdx(entity);
            //            logger.warn("getInsertedMasterIdx ret (master_idx) : " + master_idx);
        }

        int count = 0;

        // ?  db ? insert
        for (int i = 0; i < devList.size(); i++) {
            devList.get(i).put("reg_id", userId);
            devList.get(i).put("master_idx", master_idx);
            devList.get(i).put("company_name", entity.get("company_name").toString());
            devList.get(i).put("ncn", sdpApi.getNcnInfo(devList.get(i).get("ctn").toString()));
            //            devList.get(i).put("ncn", devList.get(i).get("ctn").toString() + "0001");         // test 

            //            logger.warn("devList[" + i + "] insertXlsFotaMng data : " + devList.get(i).toString());
            insertRet = listManagementSVC.insertXlsFotaMng(devList.get(i));
            //            logger.warn("devList[" + i + "] insertXlsFotaMng ret : " + insertRet);
            count++;
        }

        String msg = "? [ " + devList.size() + " ]   [ " + count
                + " ] ? ? ??.";

        //IMEI , NCN    ?  
        //         count = devList.size() - count;
        //         msg = msg + "(IMEI  : " + count + " , NCN  : " + ncnErrCnt + " )";

        retMsg = "1";
        model.addAttribute("msg", msg);

    } catch (Exception e) {
        logger.warn("?? ?   .");
        e.printStackTrace();
        upfile.delete();
        model.addAttribute("msg", "?? ?   .");
    }

    model.addAttribute("retMsg", retMsg);

    return new ModelAndView(ajaxMainView, model);
}

From source file:com.fota.fota3g.selffotaMgt.controller.ListManagementCTR.java

License:Open Source License

/**
 * confirm // w ww  . ja  v  a 2s  .  c  o  m
 * @param param
 * @param response
 * @return
 */
@RequestMapping(value = "/setXmlData_back")
@ResponseBody
public ModelAndView setXmlDataRead_back(HttpServletRequest request, HttpServletResponse response,
        @ModelAttribute("ListManagementVo") ListManagementVo vo, ModelMap model) throws Exception {
    logger.warn("#############setXmlData################");

    {
        Date now = new Date();
        logger.info("File update start : " + now.toString());

        String default_path = "F:\\servicefota\\jboss\\download\\";

        //    ? ?
        File temp_folder = new File(default_path);
        if (!temp_folder.exists() || !temp_folder.isDirectory()) {
            temp_folder.mkdirs();
        }

        // ?? : 500M
        int maxfilesize = 500 * 1024 * 1024;
        MultipartRequest multi = null;
        File upfile = null;

        try {
            //  ?
            logger.warn("#############multi start################");
            multi = new MultipartRequest(request, default_path, maxfilesize, "utf-8");
            upfile = new File(default_path + multi.getFilesystemName("file"));

            vo.setFileName(upfile.getName());
            //            logger.warn("#############multi end################" + upfile);
            //            logger.warn("#############multi end################" + upfile);
            File upfiles = new File(default_path + upfile.getName());

            FileInputStream file = new FileInputStream(upfiles);
            //            logger.warn("#############getCell model################");
            //.xlsx file
            XSSFWorkbook workbook = new XSSFWorkbook(file);
            //              logger.warn("#############getCell model################");
            // 
            XSSFSheet sheet = workbook.getSheetAt(0);
            //              logger.warn("#############getCell model################");
            //  
            Iterator<Row> rowIterator = sheet.iterator();
            //              logger.warn("#############getCell model################");
            //    ?? 
            List<ListManagementVo> rs = new ArrayList();

            // ? 
            rowIterator.next();

            while (rowIterator.hasNext()) {
                Row row = rowIterator.next();
                logger.warn("#############getCell model################" + row.cellIterator());
                //For each row, iterate through all the columns
                Iterator<Cell> cellIterator = row.cellIterator();

                ListManagementVo tmp = new ListManagementVo();
                rs.add(tmp);

                // model
                Cell cell = row.getCell(0);
                logger.warn("#############getCell model################" + cell);
                tmp.setDeviceModelName(cell.toString().trim());
                if (tmp.getDeviceModelName().length() > 50) {
                    tmp.setDeviceModelName(tmp.getDeviceModelName().substring(0, 49)); // ? 
                    logger.warn("#############getCell model################" + tmp.getDeviceModelName());
                }

                //before version
                cell = row.getCell(1);
                logger.warn("#############getCell before version################" + cell);
                tmp.setDevicePerVer(cell.toString().trim());
                if (tmp.getDevicePerVer().length() > 50) {
                    tmp.setDevicePerVer(tmp.getDevicePerVer().substring(0, 49)); // ? 
                }

                //after version
                cell = row.getCell(2);
                logger.warn("#############getCell after version################" + cell);
                tmp.setDeviceAppVer(cell.toString().trim());
                if (tmp.getDeviceAppVer().length() > 50) {
                    tmp.setDeviceAppVer(tmp.getDeviceAppVer().substring(0, 49)); // ? 
                }

                //ctn version
                cell = row.getCell(3);
                logger.warn("#############getCell ctn version################" + cell);
                tmp.setCtn(cell.toString().trim());
                if (tmp.getCtn().length() > 50) {
                    tmp.setCtn(tmp.getCtn().substring(0, 49)); // ? 
                }

                //imei version
                cell = row.getCell(4);
                logger.warn("#############getCell imei version################" + cell);
                tmp.setDeviceImei(cell.toString().trim());
                if (tmp.getDeviceImei().length() > 50) {
                    tmp.setDeviceImei(tmp.getDeviceImei().substring(0, 49)); // ? 
                }

            }

            for (ListManagementVo tmp : rs) {
                //                  mySVC.addDevInfo(tmp);
            }

            ListManagementVo footer = new ListManagementVo();
            rs.add(footer);

            file.close();
            upfile.delete();
            model.addAttribute("gridData", rs);
            //            vo.setBizTypeId(VoV.valid(multi.getParameter("bizTypeId"), 30));
            //            vo.setSvcId(VoV.valid(multi.getParameter("svcId"), 30, 4));
            //            vo.setMakerId(VoV.valid(multi.getParameter("makerId"), 30, 4));
            //            vo.setDevModelId(VoV.valid(multi.getParameter("devModelId"), 30, 4));
            //            vo.setFotaType(VoV.valid(multi.getParameter("fotaType"), 50));
            //            if (!vo.getFotaType().equals("") && !vo.getFotaType().equals("PUSH") && !vo.getFotaType().equals("POLLING") && !vo.getFotaType().equals("PUSHPOLLING"))
            //               throw new Exception();
            //            
            //            //vo.setFirmwareId(VoV.valid(multi.getParameter("firmwareId"), 30, 4));
            //            //vo.setFirmwareDesc(VoV.valid(multi.getParameter("firmwareDesc"), 1000, 9));
            //            vo.setFirmwareVer(VoV.valid(multi.getParameter("firmwareVer"), 100, 4));
            //            vo.setFirmwareMakerVer(VoV.valid(multi.getParameter("firmwareMakerVer"), 100, 8));
            //            vo.setVerMemo(VoV.valid(multi.getParameter("verMemo"), 1000, 9));
            //            
            //            //   ? ?
            //            String path = default_path + vo.getDevModelId() + "/";
            //            File pysicalfolder = new File(path);
            //            if(!pysicalfolder.exists() || !pysicalfolder.isDirectory()) {
            //               pysicalfolder.mkdirs();
            //            }
            //            vo.setFilePath(VoV.valid(path, 200));
            //            
            //            //  ???
            //            File destFile = new File(path + upfile.getName());
            //            if(destFile.exists()){
            //               destFile.delete();
            //            }
            //            FileUtils.moveFile(upfile, destFile);
            //            
            //            //CRC, '0' 
            //            vo.setCrc("0");
            //            vo.setCretNm(((UserLoginVO)request.getSession().getAttribute("userInfo")).getUserNm());
            //            
        } catch (Exception e) { //  ?? 
            // ??? ? ? 
            if (upfile != null && upfile.exists()) {
                upfile.delete();
            }

            String errorMSG = e.getMessage();
            if (errorMSG.indexOf("exceeds") != 0) {
                model.addAttribute("error", "?? 500MB ?.");
            }

            logger.info("File update error : " + errorMSG);
            response.setStatus(500);
            return new ModelAndView(ajaxMainView, model);
        }

        //      mySVC.regi(vo);

        now = new Date();
        logger.info("File update end : " + now.toString());

        //      return new ModelAndView (ajaxMainView, model);
    }
    //      int retValue = 0;
    //      vo.setModId("sooya118");
    //      vo.setConfirmState("2");
    //      
    //      retValue = listManagementSVC.updataConfirm(vo);
    //      retValue = listManagementSVC.updateHold(vo);
    //      
    //      model.addAttribute("retValue", retValue);
    //      
    return new ModelAndView(ajaxMainView, model);
}

From source file:com.fota.fotastatMgt.controller.FotastatCTR.java

License:Open Source License

/**
 *  ? //from  www.  jav  a 2  s.  c  o m
 * ?  ?.
 * @param vo
 * @param model
 * @return
 */
@RequestMapping(value = "/checkUploadExcelFile")
public ModelAndView checkUploadExcelFile(HttpServletRequest request, HttpServletResponse response,
        ModelMap model) throws Exception {

    //      logger.warn(" >>>>>>>>>> FotastatCTR - uploadExcelFil() start ... ");

    String retMsg = "";

    //   ? ?
    File pysicalFolder = new File(PATH);
    if (!pysicalFolder.exists() || !pysicalFolder.isDirectory()) {
        pysicalFolder.mkdirs();
    }

    //  ?
    MultipartRequest multi = new MultipartRequest(request, PATH, SIZE, "utf-8");
    String upFileName = multi.getFilesystemName("file");
    //      logger.warn("upFile : " + upFile);      

    FotastatSearchVO vo = new FotastatSearchVO();
    vo.setBizTypeId(VoV.valid(multi.getParameter("bizTypeId"), 30, 4));
    vo.setSvcId(VoV.valid(multi.getParameter("svcId"), 30, 4));
    vo.setDevMakerId(VoV.valid(multi.getParameter("devMakerId"), 30, 4));
    vo.setDevModelId(VoV.valid(multi.getParameter("devModelId"), 30, 4));
    vo.setModemMakerId(VoV.valid(multi.getParameter("modemMakerId"), 30, 4));
    vo.setModemModelId(VoV.valid(multi.getParameter("modemModelId"), 30, 4));
    vo.setDealerNm(VoV.valid(multi.getParameter("dealerNm"), 50, 2));

    //      logger.warn("value check...\r\n"
    //            + "bizTypeId : " + vo.getBizTypeId() + "\r\n"
    //            + "svcId : " + vo.getSvcId() + "\r\n"
    //            + "DevMakerId : " + vo.getDevMakerId() + "\r\n"
    //            + "DevModelId : " + vo.getDevModelId() + "\r\n"
    //            + "ModemMakerId : " + vo.getModemMakerId() + "\r\n"
    //            + "ModemModelId : " + vo.getModemModelId() + "\r\n"
    //            + "DealerNm : " + vo.getDealerNm() + "\r\n"
    //            );

    //  
    vo.setPage("1");
    vo.setRowsPerPage("1000");

    if (upFileName == null || upFileName.equals("")) {
        model.addAttribute("msg", "?? .");
        return new ModelAndView(ajaxMainView, model);
    }

    // poi    ? ? ?
    File upfile = new File(PATH + upFileName);

    // poi 
    try {
        FileInputStream file = new FileInputStream(upfile);

        //.xlsx file
        XSSFWorkbook workbook = new XSSFWorkbook(file);

        // 
        XSSFSheet sheet = workbook.getSheetAt(0);

        //  
        Iterator<Row> rowIterator = sheet.iterator();

        // ? ? ctn list ?
        List<String> ctnList = new ArrayList<String>();

        // ? 
        rowIterator.next();
        String tempCtn = "";
        while (rowIterator.hasNext()) {
            Row row = rowIterator.next();
            //For each row, iterate through all the columns
            Iterator<Cell> cellIterator = row.cellIterator();
            tempCtn = "";

            // ctn
            Cell cell = row.getCell(0);
            tempCtn = cell.toString().trim();
            ctnList.add(tempCtn);
        }

        // ? ctn  ? 
        // db ?   ctn  
        vo = mySVC.search(vo);
        List<String> checkedCtnList = new ArrayList<String>();

        int checkCount = 0;
        int fotaPossibilityCount = 0;
        for (int i = 0; i < ctnList.size(); i++) {
            for (int j = 0; j < vo.getResults().size(); j++) {

                if (ctnList.get(i).equals(vo.getResults().get(j).getCtn())) {
                    checkedCtnList.add(ctnList.get(i));
                    checkCount++;

                    // P(), S(), V(?)  FOTA  
                    //    W(), E(?), F() 
                    if (!((vo.getResults().get(j).getProcessStatCd().equals("")
                            || vo.getResults().get(j).getProcessStatCd().equals("P"))
                            || (vo.getResults().get(j).getProcessStatCd().equals("")
                                    || vo.getResults().get(j).getProcessStatCd().equals("S"))
                            || (vo.getResults().get(j).getProcessStatCd().equals("?")
                                    || vo.getResults().get(j).getProcessStatCd().equals("V")))) {
                        fotaPossibilityCount++;
                    }
                }
            }
        }

        retMsg = "  : " + ctnList.size() + "\r\n" + "?  : " + checkCount + "\r\n"
                + " ?  : " + (ctnList.size() - checkCount) + "\r\n" + " (?   : "
                + fotaPossibilityCount + ")";

        file.close();
        upfile.delete();
        model.addAttribute("retMsg", retMsg);
        model.addAttribute("checkedCtnList", checkedCtnList);
        model.addAttribute("fotaPossibilityCount", fotaPossibilityCount);
    } catch (Exception e) {
        logger.warn("?? ?   .");
        e.printStackTrace();
        upfile.delete();
        model.addAttribute("msg", "?? ?   .");
    }

    return new ModelAndView(ajaxMainView, model);
}

From source file:com.framework.common.ExcelSpreadsheet.java

public List<String> getSpreadSheetAsArray() {

    List<String> cellValue = new ArrayList<String>();

    // Iterate through each rows from first sheet
    Iterator<Row> rowIterator = requiredWorksheet.iterator();
    while (rowIterator.hasNext()) {
        Row row = rowIterator.next();

        // For each row, iterate through each columns
        Iterator<Cell> cellIterator = row.cellIterator();
        while (cellIterator.hasNext()) {

            Cell cell = cellIterator.next();

            switch (cell.getCellType()) {
            case Cell.CELL_TYPE_BOOLEAN:
                //                        System.out.print(cell.getBooleanCellValue() + "\t\t");
                if (cell.getBooleanCellValue()) {
                    cellValue.add("TRUE");
                } else {
                    cellValue.add("FALSE");
                }/*from  w  w  w . jav a2  s  . c o  m*/

                break;
            case Cell.CELL_TYPE_NUMERIC:
                //                        System.out.print(cell.getNumericCellValue() + "\t\t");

                if (HSSFDateUtil.isCellDateFormatted(cell)) {
                    Format formatter = new SimpleDateFormat("yyyy-MM-dd");
                    String s = formatter.format(cell.getDateCellValue());
                    cellValue.add(s);
                } else {
                    double value = cell.getNumericCellValue();
                    cellValue.add(Double.toString(value));
                }

                break;
            case Cell.CELL_TYPE_STRING:
                //                        System.out.print(cell.getStringCellValue() + "\t\t");
                cellValue.add(cell.getStringCellValue());
                break;
            }
        }
        //            System.out.println("");
    }
    return cellValue;
}

From source file:com.FuntionLibrary.java

public Boolean isCellContentPresent(XSSFSheet sheet, String content) {
    Boo = false;//from   www . ja v a 2s  . c o m
    try {
        String CellContent = null;
        // Get iterator to all the rows in current sheet
        Iterator<Row> rowIterator = sheet.iterator();
        // Traversing over each row of XLSX file
        while (rowIterator.hasNext()) {
            if (Boo == true)
                break;
            Row row = rowIterator.next();
            // For each row, iterate through each columns
            Iterator<Cell> cellIterator = row.cellIterator();
            while (cellIterator.hasNext()) {
                if (Boo == true)
                    break;
                Cell cell = cellIterator.next();

                switch (cell.getCellType()) {
                case Cell.CELL_TYPE_STRING:
                    System.out.print(cell.getStringCellValue() + "\t");
                    CellContent = cell.getStringCellValue();
                    break;
                case Cell.CELL_TYPE_NUMERIC:
                    System.out.print(cell.getNumericCellValue() + "\t");
                    CellContent = cell.getStringCellValue();
                    break;
                case Cell.CELL_TYPE_BOOLEAN:
                    System.out.print(cell.getBooleanCellValue() + "\t");
                    CellContent = cell.getStringCellValue();
                    break;
                default:
                    //CellContent = null;
                }
                if (CellContent.equalsIgnoreCase(content)) {
                    if (MainGui.EditExistingButtonClicked == true) {
                        break;

                    }
                    Boo = true;
                    break;
                    //else {
                    //                         throw new Exception("Data Already exists");
                    //                            }
                } else {
                    Boo = false;
                }
            }
            System.out.println("");
            if (MainGui.EditExistingButtonClicked == true && CellContent.equalsIgnoreCase(content)) {
                break;
            }
        }

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e.getMessage());
    }
    return Boo;
}

From source file:com.github.drbookings.excel.FileFormatBookingXLS.java

License:Open Source License

public static int getColumnIndexForIdentifier(final Row row, final String identifierBookingNumber)
        throws ExceptionFileFormat {
    final Iterator<Cell> cellIterator = row.cellIterator();
    while (cellIterator.hasNext()) {
        final Cell nextCell = cellIterator.next();
        final String cellContent = nextCell.getStringCellValue();
        if (cellContent.equals(identifierBookingNumber)) {
            return nextCell.getColumnIndex();
        }/*from   w  w  w . j  a v a  2  s . co  m*/
    }
    throw new ExceptionFileFormat("Failed to parse " + identifierBookingNumber);
}

From source file:com.gsecs.GSECSFrame.java

private void importSchoolDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importSchoolDataActionPerformed
    // TODO add your handling code here:
    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle("Please select a excel File to import");
    int result = jf.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filePath = jf.getSelectedFile().getAbsolutePath();

        try {/*from   www.  jav  a2  s .  c  o  m*/
            FileInputStream fis = new FileInputStream(filePath);
            Workbook workbook = new XSSFWorkbook(fis);
            Sheet firstSheet = workbook.getSheetAt(0);
            Iterator<Row> iterator = firstSheet.iterator();
            List<SchoolBean> schoolBeanList = new ArrayList<SchoolBean>();

            while (iterator.hasNext()) {
                Row nextRow = iterator.next();
                if (nextRow.getRowNum() != 0) {
                    Iterator<Cell> cellIterator = nextRow.cellIterator();
                    SchoolBean school = new SchoolBean();

                    while (cellIterator.hasNext()) {
                        Cell nextCell = cellIterator.next();
                        int columnIndex = nextCell.getColumnIndex();

                        switch (columnIndex) {
                        case 0:
                            school.setSchoolAbbrv((String) getCellValue(nextCell));
                            break;
                        case 1:
                            school.setSchoolName((String) getCellValue(nextCell));
                            break;

                        }

                    }
                    schoolBeanList.add(school);
                }

            }
            workbook.close();
            fis.close();

            mainPanel.removeAll();
            mainPanel.repaint();
            GradSchoolModel model = new GradSchoolModel();
            GradSchoolJInternalFrame schoolFrame = new GradSchoolJInternalFrame();
            schoolFrame.getSchoolMsgLabel().setText("");
            schoolFrame.getAddSchoolButton().setVisible(true);
            schoolFrame.getUpdateSchoolButton().setVisible(false);
            schoolFrame.getDeleteSchoolButton().setVisible(false);
            //schoolFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools()));
            for (SchoolBean schoolBean : schoolBeanList) {
                try {
                    model.addSchool(schoolBean);
                } catch (Exception exp) {
                    System.out.println("Exception Raised....." + exp.getMessage());
                }
            }
            schoolFrame.loadDataIntoJTable();
            mainPanel.add(schoolFrame);
            schoolFrame.setVisible(true);
        } catch (Exception exp) {
            JOptionPane.showMessageDialog(null, exp.getMessage());
        }

    }

}

From source file:com.gsecs.GSECSFrame.java

private void facultyImportMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_facultyImportMenuItemActionPerformed
    // TODO add your handling code here:
    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle("Please select a excel File to import");
    int result = jf.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filePath = jf.getSelectedFile().getAbsolutePath();

        try {//  w  ww .  jav  a 2s  . c  om
            FileInputStream fis = new FileInputStream(filePath);
            Workbook workbook = new XSSFWorkbook(fis);
            Sheet firstSheet = workbook.getSheetAt(0);
            Iterator<Row> iterator = firstSheet.iterator();
            List<FacultyBean> facultyBeanList = new ArrayList<FacultyBean>();

            while (iterator.hasNext()) {
                Row nextRow = iterator.next();
                if (nextRow.getRowNum() != 0) {
                    Iterator<Cell> cellIterator = nextRow.cellIterator();
                    FacultyBean faculty = new FacultyBean();

                    while (cellIterator.hasNext()) {
                        Cell nextCell = cellIterator.next();
                        int columnIndex = nextCell.getColumnIndex();

                        switch (columnIndex) {
                        case 0:
                            faculty.setLastName((String) getCellValue(nextCell));
                            break;
                        case 1:
                            faculty.setFirstName((String) getCellValue(nextCell));
                            break;
                        case 2:
                            faculty.setGradSchool((String) getCellValue(nextCell));
                            break;
                        case 3:
                            faculty.setDegree((String) getCellValue(nextCell));
                            break;
                        case 4:
                            faculty.setTitle((String) getCellValue(nextCell));
                            break;
                        case 5:
                            faculty.setDaysToTeach(getCellValue(nextCell).toString());
                            break;
                        case 6:
                            faculty.setMaxLoadFall(Double.valueOf(getCellValue(nextCell).toString()));
                            break;
                        case 7:
                            faculty.setMaxLoadSpring(Double.valueOf(getCellValue(nextCell).toString()));
                            break;
                        case 8:
                            faculty.setMaxLoadSummer(Double.valueOf(getCellValue(nextCell).toString()));
                            break;
                        }

                    }
                    facultyBeanList.add(faculty);
                }

            }
            workbook.close();
            fis.close();

            mainPanel.removeAll();
            mainPanel.repaint();
            FacultyModel model = new FacultyModel();
            FacultyJInternalFrame facultyFrame = new FacultyJInternalFrame();
            facultyFrame.getFacultyMsgLabel().setText("");
            facultyFrame.getAddFacultyButton().setVisible(true);
            facultyFrame.getUpdateFacultyButton().setVisible(false);
            facultyFrame.getDeleteFacultyButton().setVisible(false);
            //schoolFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools()));
            for (FacultyBean facultyBean : facultyBeanList) {
                try {
                    model.addFaculty(facultyBean);
                } catch (Exception exp) {
                    System.out.println("Exception Raised....." + exp.getMessage());
                }
            }
            facultyFrame.loadDataIntoJTable();
            mainPanel.add(facultyFrame);
            facultyFrame.setVisible(true);
        } catch (Exception exp) {
            JOptionPane.showMessageDialog(null, exp.getMessage());
        }

    }
}