Example usage for org.apache.poi.ss.usermodel Sheet getRow

List of usage examples for org.apache.poi.ss.usermodel Sheet getRow

Introduction

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

Prototype

Row getRow(int rownum);

Source Link

Document

Returns the logical row (not physical) 0-based.

Usage

From source file:com.kongwu.insweb.utils.ReadExcel.java

License:Apache License

/**
 * @param filepath excel//from   ww  w  .  j a  v a  2 s  .  c o m
 *        
 *        
 *        
 * @return ??,:list<usrid,query,biz,semantic>
 *                        :
 *                           :
 * @throws IOException
 */
public static List<List<String>> readTestset(String filepath) throws IOException {
    FileInputStream fileIn = null;
    List<List<String>> testsetList = new ArrayList<List<String>>();
    /**?excel**/
    try {
        fileIn = new FileInputStream(filepath);
        /**excel 2007**/
        if (filepath.endsWith(".xlsx")) {
            Workbook wb = new XSSFWorkbook(fileIn);
            Sheet sheet = wb.getSheetAt(0);
            Row row = null;
            Cell cell = null;
            int rowSize = sheet.getLastRowNum() + 1;// getLastRowNum()1
            logger.info("?" + rowSize);
            if (rowSize < 2)
                return null;
            // ?,
            for (int i = 1; i < rowSize; i++) {
                row = sheet.getRow(i);
                if (row == null)
                    continue;
                int cellSize = row.getLastCellNum();
                logger.info("?" + cellSize);
                /**
                 * ?cell
                 */
                List<String> list = new ArrayList<String>();
                for (int j = 0; j < cellSize; j++) {
                    cell = row.getCell(i);
                    if (cell != null) {
                        list.add(cell.toString());
                    }
                }

                testsetList.add(list);
            }
        } else {
            POIFSFileSystem fs = new POIFSFileSystem(fileIn);
            HSSFWorkbook wb = new HSSFWorkbook(fs);
            HSSFSheet sheet = wb.getSheetAt(0);
            HSSFRow row = null;
            HSSFCell cell = null;
            int rowSize = sheet.getLastRowNum() + 1;// getLastRowNum()1
            logger.info("?" + rowSize);
            if (rowSize < 2)// ???
                return null;
            // ?,
            for (int i = 1; i < rowSize; i++) {
                row = sheet.getRow(i);
                if (row == null)
                    continue;
                int cellSize = row.getLastCellNum();
                logger.info("?" + cellSize);
                List<String> list = new ArrayList<String>();
                for (int j = 0; j < cellSize; j++) {
                    cell = row.getCell(j);
                    if (cell != null) {
                        list.add(cell.toString());
                    }
                }
                testsetList.add(list);
            }
        }
    } finally {
        if (fileIn != null)
            fileIn.close();
    }
    return testsetList;
}

From source file:com.kysoft.cpsi.audit.service.SelfCheckServiceImpl.java

private void nianbaoWangzhiwangdian(Hcrw hcrw, Sheet sheetZCB, Integer nd) {

    try {//from   ww  w  . j a  v a  2  s.c om
        //?
        if (null != POIUtils.getCellFormatValue(sheetZCB.getRow(7).getCell(3)).trim()
                && !POIUtils.getCellFormatValue(sheetZCB.getRow(7).getCell(3)).trim().equals("")) {
            Homepage homepage = new Homepage();
            homepage.setNd(nd);
            homepage.setXydm(hcrw.getHcdwXydm());
            homepage.setId(UUID.randomUUID().toString().replace("-", ""));

            homepage.setName("??");
            homepage.setType("??");
            homepage.setWz(POIUtils.getCellFormatValue(sheetZCB.getRow(7).getCell(3)));
            //??
            homepageMapper.deleteByTaskIdNd(hcrw.getId(), nd);
            //??
            homepageMapper.insert2(homepage);
        }
    } catch (Exception e) {
        e.printStackTrace();
        MongoLogger.warn("?? ? ", ExceptionUtils.getStackTrace(e),
                hcrw.getId());
        throw new RuntimeException(
                "[??][??]??;");
    }
}

From source file:com.kysoft.cpsi.audit.service.SelfCheckServiceImpl.java

private void nianbao(Hcrw hcrw, Sheet sheetZCFZB, Sheet sheetZCB, Sheet sheetLRB, Integer nd) {
    String errorMsg = "";
    try {/*  w ww.j ava2s  . c om*/
        DecimalFormat decimalFormat = new DecimalFormat("#.00");
        //?
        AnnualReport annualReport = new AnnualReport();
        annualReport.setNd(nd);
        annualReport.setXydm(hcrw.getHcdwXydm());
        annualReport.setQymc(hcrw.getHcdwName());
        errorMsg = "??";
        annualReport.setSyzqyhj(parseFloat(decimalFormat
                .format(parseFloat(POIUtils.getCellFormatValue(sheetZCFZB.getRow(47).getCell(10))) / 10000)));

        //?
        errorMsg = "?";
        Float lrze = parseFloat(POIUtils.getCellFormatValue(sheetLRB.getRow(6).getCell(3)))
                - parseFloat(POIUtils.getCellFormatValue(sheetLRB.getRow(9).getCell(3)))
                - parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(12).getCell(3)))
                - parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(13).getCell(3)))
                - parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(14).getCell(3)))
                - parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(15).getCell(3)))
                - parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(16).getCell(3)))
                + parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(18).getCell(3)))
                + parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(19).getCell(3)))
                + parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(21).getCell(3)))
                - parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(23).getCell(3)));
        annualReport.setLrze(parseFloat(decimalFormat.format(lrze / 10000)));
        //
        errorMsg = "";
        Float jlr = lrze - parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(26).getCell(3)));
        annualReport.setJlr(parseFloat(decimalFormat.format(jlr / 10000)));

        errorMsg = "?";
        annualReport.setYyzsr(parseFloat(decimalFormat
                .format(parseFloat(POIUtils.getCellFormatValue(sheetLRB.getRow(6).getCell(3))) / 10000)));
        errorMsg = "?";
        annualReport.setZyywsr(parseFloat(decimalFormat
                .format(parseFloat(POIUtils.getStringCellValue(sheetLRB.getRow(7).getCell(3))) / 10000)));
        errorMsg = "?";
        annualReport.setNsze(parseFloat(
                decimalFormat.format(parseFloat(POIUtils.getStringCellValue(sheetZCB.getRow(9).getCell(5))))));
        errorMsg = "?";
        annualReport.setFzze(parseFloat(decimalFormat
                .format(parseFloat(POIUtils.getCellFormatValue(sheetZCFZB.getRow(35).getCell(10))) / 10000)));
        errorMsg = "?";
        annualReport.setZcze(parseFloat(decimalFormat
                .format(parseFloat(POIUtils.getCellFormatValue(sheetZCFZB.getRow(48).getCell(5))) / 10000)));

        errorMsg = "?";
        annualReport.setTxdz(POIUtils.getStringCellValue(sheetZCB.getRow(6).getCell(3)));
        errorMsg = "?";
        annualReport.setYzbm(POIUtils.getStringCellValue(sheetZCB.getRow(8).getCell(5)));
        errorMsg = "??";
        annualReport.setLxdh(POIUtils.getStringCellValue(sheetZCB.getRow(5).getCell(5)));
        errorMsg = "?";
        annualReport.setMail(POIUtils.getStringCellValue(sheetZCB.getRow(6).getCell(5)));

        errorMsg = "";
        annualReport.setCyrs(parseInt(POIUtils.getStringCellValue(sheetZCB.getRow(7).getCell(5))));
        errorMsg = "";
        annualReport.setGxbysGg(0);
        errorMsg = "??";
        annualReport.setGxbysJy(0);
        errorMsg = "";
        annualReport.setTysbsGg(0);
        errorMsg = "??";
        annualReport.setTysbsJy(0);
        errorMsg = "";
        annualReport.setCjrsGg(0);
        errorMsg = "??";
        annualReport.setCjrsJy(0);
        errorMsg = "?";
        annualReport.setZjysGg(0);
        errorMsg = "???";
        annualReport.setZjysJy(0);

        errorMsg = "???";
        annualReport.setJyzt(POIUtils.getStringCellValue(sheetZCB.getRow(8).getCell(3)));
        errorMsg = "??";
        annualReport.setSftzgmgq(POIUtils.getStringCellValue(sheetZCB.getRow(13).getCell(4)));
        errorMsg = "???";
        annualReport.setSfydwdbxx(POIUtils.getStringCellValue(sheetZCB.getRow(14).getCell(4)));
        //??
        annualReportMapper.deleteByTaskIdNd2(hcrw.getId(), nd);
        //??
        annualReportMapper.insert2(annualReport);
    } catch (Exception e) {
        e.printStackTrace();
        MongoLogger.warn("?? ? ",
                ExceptionUtils.getStackTrace(e), hcrw.getId());
        throw new RuntimeException(
                "[??? " + errorMsg + "]??;");
    }
}

From source file:com.kysoft.cpsi.audit.service.SelfCheckServiceImpl.java

private void gudongchuzi(Hcrw hcrw, Sheet sheetGDCZ, Integer nd) {
    try {//from   w  ww. ja v  a 2 s. c o m
        stockholderContributionMapper.deleteByTaskIdNd(hcrw.getId(), nd);
        // 
        int rowNum = sheetGDCZ.getLastRowNum();
        for (int i = 6; i < rowNum; i++) {
            if (null != POIUtils.getStringCellValue(sheetGDCZ.getRow(i).getCell(2)).trim()
                    && !POIUtils.getStringCellValue(sheetGDCZ.getRow(i).getCell(2)).trim().equals("")) {
                StockholderContribution stockholderContribution = new StockholderContribution();
                stockholderContribution.setId(UUID.randomUUID().toString().replace("-", ""));
                stockholderContribution.setNd(nd);
                stockholderContribution.setXydm(hcrw.getHcdwXydm());
                stockholderContribution.setGd(POIUtils.getStringCellValue(sheetGDCZ.getRow(i).getCell(2)));
                stockholderContribution.setRjcze(null);
                stockholderContribution.setRjczdqsj(null);
                stockholderContribution.setRjczfs(null);
                stockholderContribution
                        .setSjcze(parseFloat(POIUtils.getStringCellValue(sheetGDCZ.getRow(i).getCell(3))));
                stockholderContribution.setSjczsj(POIUtils.getStringCellValue(sheetGDCZ.getRow(i).getCell(4)));
                stockholderContribution.setSjczfs(POIUtils.getStringCellValue(sheetGDCZ.getRow(i).getCell(5)));
                stockholderContributionMapper.insert2(stockholderContribution);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        MongoLogger.warn("?? ?? ",
                ExceptionUtils.getStackTrace(e), hcrw.getId());
        throw new RuntimeException("[??]??;");
    }
}

From source file:com.kysoft.cpsi.audit.service.SelfCheckServiceImpl.java

private void guquanbiangeng(Hcrw hcrw, Sheet sheetGQBG, Integer nd) {
    try {//from  ww  w  .j a  v a2s. c  om
        stockRightChangeMapper.deleteByTaskIdNd(hcrw.getId(), nd);
        // 
        int rowNum = sheetGQBG.getLastRowNum();
        for (int i = 6; i < rowNum; i++) {
            if (null != POIUtils.getStringCellValue(sheetGQBG.getRow(i).getCell(2)).trim()
                    && !POIUtils.getStringCellValue(sheetGQBG.getRow(i).getCell(2)).trim().equals("")) {
                StockRightChange stockRightChange = new StockRightChange();
                stockRightChange.setId(UUID.randomUUID().toString().replace("-", ""));
                stockRightChange.setNd(nd);
                stockRightChange.setXydm(hcrw.getHcdwXydm());
                stockRightChange.setGd(POIUtils.getStringCellValue(sheetGQBG.getRow(i).getCell(2)));
                stockRightChange.setBgqGqbl(
                        parseFloat(POIUtils.getStringCellValue(sheetGQBG.getRow(i).getCell(3))) * 100);
                stockRightChange.setBghGqbl(
                        parseFloat(POIUtils.getStringCellValue(sheetGQBG.getRow(i).getCell(4))) * 100);
                stockRightChange.setBgrq(POIUtils.getStringCellValue(sheetGQBG.getRow(i).getCell(5)));
                stockRightChangeMapper.insert2(stockRightChange);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        MongoLogger.warn("?? ???? ",
                ExceptionUtils.getStackTrace(e), hcrw.getId());
        throw new RuntimeException("[????]??;");
    }
}

From source file:com.kysoft.cpsi.audit.service.SelfCheckServiceImpl.java

private void duiwaitouzi(Hcrw hcrw, Sheet sheetDWTZ, Integer nd) {
    try {//from w w  w . j a v a 2s  .com
        investmentMapper.deleteByTaskIdNd(hcrw.getId(), nd);
        // 
        int rowNum = sheetDWTZ.getLastRowNum();
        for (int i = 5; i < rowNum; i++) {
            if (null != POIUtils.getStringCellValue(sheetDWTZ.getRow(i).getCell(3)).trim()
                    && !POIUtils.getStringCellValue(sheetDWTZ.getRow(i).getCell(3)).trim().equals("")) {
                Investment investment = new Investment();
                investment.setId(UUID.randomUUID().toString().replace("-", ""));
                investment.setNd(nd);
                investment.setXydm(hcrw.getHcdwXydm());
                investment.setTzqymc(POIUtils.getStringCellValue(sheetDWTZ.getRow(i).getCell(2)));
                investment.setTzqyZch(POIUtils.getStringCellValue(sheetDWTZ.getRow(i).getCell(3)));
                investmentMapper.insert2(investment);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        MongoLogger.warn("?? ????? ",
                ExceptionUtils.getStackTrace(e), hcrw.getId());
        throw new RuntimeException("[?????]??;");
    }
}

From source file:com.kysoft.cpsi.audit.service.SelfCheckServiceImpl.java

private void duiwandanbao(Hcrw hcrw, Sheet sheetDWDB, Integer nd) {
    try {/* w  ww  .  j av  a 2 s  .  c  o  m*/
        guaranteeMapper.deleteByTaskIdNd(hcrw.getId(), nd);
        // 
        int rowNum = sheetDWDB.getLastRowNum();
        for (int i = 5; i < rowNum; i++) {
            if (null != POIUtils.getStringCellValue(sheetDWDB.getRow(i).getCell(2)).trim()
                    && !POIUtils.getStringCellValue(sheetDWDB.getRow(i).getCell(2)).trim().equals("")) {
                Guarantee guarantee = new Guarantee();
                guarantee.setId(UUID.randomUUID().toString().replace("-", ""));
                guarantee.setNd(nd);
                guarantee.setXydm(hcrw.getHcdwXydm());
                guarantee.setZqr(POIUtils.getStringCellValue(sheetDWDB.getRow(i).getCell(2)));
                guarantee.setZwr(POIUtils.getStringCellValue(sheetDWDB.getRow(i).getCell(3)));
                guarantee.setZzqzl(POIUtils.getStringCellValue(sheetDWDB.getRow(i).getCell(4)));
                guarantee.setZzqse(parseFloat(POIUtils.getStringCellValue(sheetDWDB.getRow(i).getCell(5))));
                guarantee.setLxzwqx(POIUtils.getStringCellValue(sheetDWDB.getRow(i).getCell(6)));
                guarantee.setBzqj(POIUtils.getStringCellValue(sheetDWDB.getRow(i).getCell(7)));
                guarantee.setBzfs(POIUtils.getStringCellValue(sheetDWDB.getRow(i).getCell(8)));
                guarantee.setBzdbfw(POIUtils.getStringCellValue(sheetDWDB.getRow(i).getCell(9)));
                guaranteeMapper.insert2(guarantee);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        MongoLogger.warn("?? ?? ",
                ExceptionUtils.getStackTrace(e), hcrw.getId());
        throw new RuntimeException("[??]??;");
    }
}

From source file:com.kysoft.cpsi.audit.service.SelfCheckServiceImpl.java

private void xingzhengxuke(Hcrw hcrw, Sheet sheetXZXK, Integer nd) {
    try {/*from   w ww  .j a  v a2 s .c om*/
        licenseMapper.deleteByTaskIdNd(hcrw.getId(), nd);
        // 
        int rowNum = sheetXZXK.getLastRowNum();
        for (int i = 5; i < rowNum; i++) {
            if (null != POIUtils.getStringCellValue(sheetXZXK.getRow(i).getCell(2)).trim()
                    && !POIUtils.getStringCellValue(sheetXZXK.getRow(i).getCell(2)).trim().equals("")) {
                License license = new License();
                license.setId(UUID.randomUUID().toString().replace("-", ""));
                license.setNd(nd);
                license.setXydm(hcrw.getHcdwXydm());
                license.setXkwjmc(POIUtils.getStringCellValue(sheetXZXK.getRow(i).getCell(3)));
                license.setYxq(POIUtils.getStringCellValue(sheetXZXK.getRow(i).getCell(4)) + "-"
                        + POIUtils.getStringCellValue(sheetXZXK.getRow(i).getCell(5)));
                licenseMapper.insert2(license);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        MongoLogger.warn("?? ?????? ",
                ExceptionUtils.getStackTrace(e), hcrw.getId());
        throw new RuntimeException("[??????]??;");
    }
}

From source file:com.kysoft.cpsi.audit.service.SelfCheckServiceImpl.java

private void jsGudongchuzhi(Hcrw hcrw, Sheet sheet) throws Exception {
    try {/*ww  w .  j  av a 2s .c  om*/
        jsStockholderContributionMapper.deleteByTaskId2(hcrw.getId());
        // 
        int rowNum = sheet.getLastRowNum();
        for (int i = 6; i < rowNum; i++) {
            if (null != POIUtils.getStringCellValue(sheet.getRow(i).getCell(2)).trim()
                    && !POIUtils.getStringCellValue(sheet.getRow(i).getCell(2)).trim().equals("")) {
                JsStockholderContribution jsStockholderContribution = new JsStockholderContribution();
                jsStockholderContribution.setId("");
                jsStockholderContribution.setXydm(hcrw.getHcdwXydm());
                jsStockholderContribution.setGd(POIUtils.getStringCellValue(sheet.getRow(i).getCell(2)));
                jsStockholderContribution
                        .setBgrq(getDateValue(POIUtils.getStringCellValue(sheet.getRow(i).getCell(4))));
                jsStockholderContribution.setRje(null);
                jsStockholderContribution
                        .setSje(new BigDecimal(POIUtils.getStringCellValue(sheet.getRow(i).getCell(3))));
                jsStockholderContribution.setGssj(null);
                jsStockholderContribution.setRjczfs(null);
                jsStockholderContribution.setRjcze(null);
                jsStockholderContribution.setRjczrq(null);
                jsStockholderContribution.setSjczfs(POIUtils.getStringCellValue(sheet.getRow(i).getCell(5)));
                jsStockholderContribution
                        .setSjcze(new BigDecimal(POIUtils.getStringCellValue(sheet.getRow(i).getCell(3))));
                jsStockholderContribution
                        .setSjczrq(getDateValue(POIUtils.getStringCellValue(sheet.getRow(i).getCell(4))));
                jsStockholderContributionMapper.insert2(jsStockholderContribution);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        MongoLogger.warn("?? ?? ? ",
                ExceptionUtils.getStackTrace(e), hcrw.getId());
        throw new RuntimeException("[??](?)??;");
    }
}

From source file:com.kysoft.cpsi.audit.service.SelfCheckServiceImpl.java

private void jsGuquanbiangeng(Hcrw hcrw, Sheet sheet) throws Exception {
    try {/*w w  w  .ja va 2  s .co m*/
        jsGqbgMapper.deleteByTaskId2(hcrw.getId());
        // 
        int rowNum = sheet.getLastRowNum();
        for (int i = 6; i < rowNum; i++) {
            if (null != POIUtils.getStringCellValue(sheet.getRow(i).getCell(2)).trim()
                    && !POIUtils.getStringCellValue(sheet.getRow(i).getCell(2)).trim().equals("")) {
                JsGqbg jsGqbg = new JsGqbg();
                jsGqbg.setId("");
                jsGqbg.setXydm(hcrw.getHcdwXydm());
                jsGqbg.setGd(POIUtils.getStringCellValue(sheet.getRow(i).getCell(2)));
                jsGqbg.setBgrq(getDateValue(POIUtils.getStringCellValue(sheet.getRow(i).getCell(5))));
                jsGqbg.setBgqbl(new BigDecimal(POIUtils.getStringCellValue(sheet.getRow(i).getCell(3))));
                jsGqbg.setBghbl(new BigDecimal(POIUtils.getStringCellValue(sheet.getRow(i).getCell(4))));
                jsGqbg.setGssj(null);
                jsGqbgMapper.insert2(jsGqbg);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        MongoLogger.warn("?? ???? ? ",
                ExceptionUtils.getStackTrace(e), hcrw.getId());
        throw new RuntimeException(
                "[????](?)??;");
    }
}