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

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

Introduction

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

Prototype

int getRowNum();

Source Link

Document

Get row number this row represents

Usage

From source file:com.photon.phresco.framework.commons.FrameworkUtil.java

License:Apache License

private void writeTestCaseToXLS(String testSuiteName, String[] cellValue, String status, int numCol, int cellno,
        CellStyle[] tryStyle, StringBuilder sb) throws PhrescoException {
    Iterator<Row> rowIterator;
    try {//from w  w w . ja  v  a 2  s . c o  m
        FileInputStream myInput = new FileInputStream(sb.toString());
        HSSFWorkbook myWorkBook = new HSSFWorkbook(myInput);
        int numberOfSheets = myWorkBook.getNumberOfSheets();
        for (int j = 0; j < numberOfSheets; j++) {
            HSSFSheet myHssfSheet = myWorkBook.getSheetAt(j);
            if (myHssfSheet.getSheetName().equals(testSuiteName)) {
                rowIterator = myHssfSheet.rowIterator();
                Row next;
                for (Cell cell : myHssfSheet.getRow((myHssfSheet.getLastRowNum()) - 1)) {
                    tryStyle[cellno] = cell.getCellStyle();
                    cellno = cellno + 1;
                    if (cellno == 15) {
                        break;
                    }
                }
                float totalPass = 0;
                float totalFail = 0;
                float totalNotApp = 0;
                float totalBlocked = 0;
                float notExecuted = 0;
                float totalTestCases = 0;
                for (int i = 0; i <= 22; i++) {
                    rowIterator.next();
                }

                do {
                    next = rowIterator.next();
                    if (StringUtils.isNotEmpty(getValue(next.getCell(1)))
                            && !getValue(next.getCell(0)).equalsIgnoreCase("S.NO")) {
                        String value = getValue(next.getCell(11));
                        if (StringUtils.isNotEmpty(value)) {
                            if (value.equalsIgnoreCase("success")) {
                                totalPass = totalPass + 1;
                            } else if (value.equalsIgnoreCase("failure")) {
                                totalFail = totalFail + 1;
                            } else if (value.equalsIgnoreCase("notApplicable")) {
                                totalNotApp = totalNotApp + 1;
                            } else if (value.equalsIgnoreCase("blocked")) {
                                totalBlocked = totalBlocked + 1;
                            }
                        } else {
                            notExecuted = notExecuted + 1;
                        }
                    }
                } while (rowIterator.hasNext());
                //to update the status in the index page 
                if (status.equalsIgnoreCase("success")) {
                    totalPass = totalPass + 1;
                } else if (status.equalsIgnoreCase("failure")) {
                    totalFail = totalFail + 1;
                } else if (status.equalsIgnoreCase("notApplicable")) {
                    totalNotApp = totalNotApp + 1;
                } else if (status.equalsIgnoreCase("blocked")) {
                    totalBlocked = totalBlocked + 1;
                } else {
                    notExecuted = notExecuted + 1;
                }
                totalTestCases = totalPass + totalFail + totalNotApp + totalBlocked + notExecuted;
                HSSFSheet mySheetHssf = myWorkBook.getSheetAt(0);
                rowIterator = mySheetHssf.rowIterator();
                for (int i = 0; i <= 2; i++) {
                    rowIterator.next();
                }
                while (rowIterator.hasNext()) {
                    Row next1 = rowIterator.next();
                    if (StringUtils.isNotEmpty(getValue(next1.getCell(2)))
                            && !getValue(next1.getCell(2)).equalsIgnoreCase("Total")) {
                        TestSuite createObject = createObject(next1);
                        if (createObject.getName().equals(testSuiteName)) {
                            addCalculationsToIndex(totalPass, totalFail, totalNotApp, totalBlocked, notExecuted,
                                    totalTestCases, next1);
                        }
                    }
                }
                Row r = null;
                if (myHssfSheet.getSheetName().equalsIgnoreCase("Index")) {
                    r = myHssfSheet.createRow(next.getRowNum() - 1);

                } else {
                    r = myHssfSheet.createRow(next.getRowNum() + 1);
                }
                for (int i = 0; i < numCol; i++) {
                    Cell cell = r.createCell(i);
                    cell.setCellValue(cellValue[i]);
                    if (tryStyle[i] != null) {
                        cell.setCellStyle(tryStyle[i]);
                    }
                }
                FileOutputStream fileOut = new FileOutputStream(sb.toString());
                myWorkBook.write(fileOut);
                myInput.close();
                fileOut.close();
            }

        }
    } catch (PhrescoException e) {
        throw new PhrescoException(e);
    } catch (FileNotFoundException e) {
        throw new PhrescoException(e);
    } catch (IOException e) {
        throw new PhrescoException(e);
    }
}

From source file:com.photon.phresco.service.tools.TechnologyDataGenerator.java

License:Apache License

/**
 * Handle dependencies./*from w ww  .  j a  v  a 2 s .c  o m*/
 *
 * @param modules
 *            the modules
 * @return the modules
 */
//   private Modules handleDependencies(Modules modules) {
//      Modules modifiedModules = new Modules();
//      List<Module> moduleList = modules.getModule();
//      for (Module module : moduleList) {
//         List<String> depModNameList = new ArrayList<String>();
//         String modName = module.getId();
//         String[] depList = NAME_AND_DEP_MAP.get(modName);
//         if (depList == null) {
//            modifiedModules.getModule().add(module);
//            continue;
//         }
//         for (String dep : depList) {
//            int depNo = (int) (Double.valueOf(dep).doubleValue());
//            String depModName = SNO_AND_NAME_MAP.get(String.valueOf(depNo));
//            depModNameList.add(depModName);
//         }
//
//         if (!depModNameList.isEmpty()) {
//            module.getDependentModules().addAll(depModNameList);
//         }
//
//         modifiedModules.getModule().add(module);
//      }
//      return modifiedModules;
//   }

private ModuleGroup createModuleGroup(String techId, Row row) throws PhrescoException {
    if (S_LOGGER.isDebugEnabled()) {
        S_LOGGER.debug("row " + row.getRowNum());
    }
    ModuleGroup moduleGroup = new ModuleGroup();

    Cell serialNo = row.getCell(0);
    if (serialNo == null || Cell.CELL_TYPE_BLANK == serialNo.getCellType()) {
        return null;
    }

    String name = row.getCell(1).getStringCellValue();

    String identifier = ID + row.getCell(1).getStringCellValue().toLowerCase()
            .replace(ServerConstants.STR_BLANK_SPACE, ServerConstants.STR_UNDER_SCORE);
    String no = String.valueOf(identifier);

    String version = "1.0";
    Cell versionCell = row.getCell(2);
    String[] versionArray = null;
    if (versionCell != null && Cell.CELL_TYPE_BLANK != versionCell.getCellType()) {
        String versions = getValue(versionCell);
        versionArray = StringUtils.split(versions, DELIMITER);
        NAME_AND_DEP_MAP.put(identifier, versionArray);
    }

    Cell requireCell = row.getCell(3);
    String[] reqArray = null;
    if (requireCell != null && Cell.CELL_TYPE_BLANK != requireCell.getCellType()) {
        String reqs = getValue(requireCell);
        reqArray = StringUtils.split(reqs, DELIMITER);
    }

    Cell coreCell = row.getCell(4);
    String[] coreArray = null;
    if (coreCell != null && Cell.CELL_TYPE_BLANK != coreCell.getCellType()) {
        String core = getValue(coreCell);
        coreArray = StringUtils.split(core, DELIMITER);
    }

    int sNoInt = (int) serialNo.getNumericCellValue();
    SNO_AND_NAME_MAP.put(String.valueOf(sNoInt), identifier);

    Cell depCell = row.getCell(5);
    if (depCell != null && Cell.CELL_TYPE_BLANK != depCell.getCellType()) {
        String depModules = getValue(depCell);
        String[] depModuleIds = StringUtils.split(depModules, DELIMITER);
        NAME_AND_DEP_MAP.put(identifier, depModuleIds);
    }

    List<Documentation> docs = new ArrayList<Documentation>();
    Cell helptext = row.getCell(9);
    if (helptext != null && Cell.CELL_TYPE_BLANK != helptext.getCellType()) {
        Documentation doc = new Documentation();
        String docContent = helptext.getStringCellValue();
        doc.setContent(docContent);
        doc.setType(DocumentationType.HELP_TEXT);
        docs.add(doc);
    }

    Cell description = row.getCell(12);
    if (description != null && Cell.CELL_TYPE_BLANK != description.getCellType()) {
        Documentation doc = new Documentation();
        String docContent = description.getStringCellValue();
        doc.setContent(docContent);
        doc.setType(DocumentationType.DESCRIPTION);
        docs.add(doc);

    }
    moduleGroup.setDocs(docs);

    String fileExt = "zip";
    Cell filenameCell = row.getCell(13);
    if (filenameCell != null && Cell.CELL_TYPE_BLANK != filenameCell.getCellType()) {
        if (S_LOGGER.isDebugEnabled()) {
            S_LOGGER.debug("no " + no);
            S_LOGGER.debug("filename.getCellType() " + filenameCell.getCellType());
        }

        String filePath = filenameCell.getStringCellValue().trim();

        if (filePath.endsWith(".tar.gz")) {
            fileExt = "tar.gz";
        } else if (filePath.endsWith(".tar")) {
            fileExt = "tar";
        } else if (filePath.endsWith(".zip")) {
            fileExt = "zip";
        } else if (filePath.endsWith(".jar")) {
            fileExt = "jar";
        }

        //      publishModule(tech, module, filePath, fileExt);
    }

    List<Module> modulesList = createModuleList(versionArray, reqArray, coreArray, techId, fileExt, identifier);

    Cell imagenameCell = row.getCell(16);
    if (imagenameCell != null && Cell.CELL_TYPE_BLANK != imagenameCell.getCellType()) {

        String imagePath = imagenameCell.getStringCellValue().trim();
        //        String imageUrl = createImageContentUrl("");
        //         module.setImageURL(imageUrl);
        moduleGroup.setImageURL(imagePath);
    }

    Cell groupNameCell = row.getCell(14);
    if (groupNameCell != null && Cell.CELL_TYPE_BLANK != groupNameCell.getCellType()) {
        if (S_LOGGER.isDebugEnabled()) {
            S_LOGGER.debug("no " + no);
            S_LOGGER.debug("groupname.getCellType() " + groupNameCell.getCellType());
        }
        String groupId = groupNameCell.getStringCellValue();
        moduleGroup.setGroupId(groupId);
    }

    Cell artifactCell = row.getCell(15);
    if (artifactCell != null && Cell.CELL_TYPE_BLANK != artifactCell.getCellType()) {
        if (S_LOGGER.isDebugEnabled()) {
            S_LOGGER.debug("no " + no);
            S_LOGGER.debug("artifact name.getCellType() " + artifactCell.getCellType());
        }
        String artifactId = artifactCell.getStringCellValue();
        moduleGroup.setArtifactId(artifactId);
    }
    moduleGroup.setName(name);
    moduleGroup.setTechId(techId);
    moduleGroup.setVersions(modulesList);
    moduleGroup.setSystem(true);
    moduleGroup.setModuleId(identifier);
    moduleGroup.setType("module");
    moduleGroup.setCustomerId("photon");
    return moduleGroup;
}

From source file:com.plugin.excel.util.ExcelUtil.java

License:Apache License

/**
 * @param srcSheet//from w ww  .j a  v  a 2s .c om
 *            the sheet to copy.
 * @param destSheet
 *            the sheet to create.
 * @param srcRow
 *            the row to copy.
 * @param destRow
 *            the row to create.
 * @param styleMap
 *            -
 */
public static void copyRow(SXSSFSheet srcSheet, SXSSFSheet destSheet, Row srcRow, Row destRow,
        Map<Integer, CellStyle> styleMap) {
    // manage a list of merged zone in order to not insert two times a
    // merged zone
    Set<CellRangeAddressWrapper> mergedRegions = new TreeSet<CellRangeAddressWrapper>();
    destRow.setHeight(srcRow.getHeight());
    // pour chaque row
    for (int j = srcRow.getFirstCellNum(); j <= srcRow.getLastCellNum(); j++) {
        Cell oldCell = srcRow.getCell(j); // ancienne cell
        Cell newCell = destRow.getCell(j); // new cell
        if (oldCell != null) {
            if (newCell == null) {
                newCell = destRow.createCell(j);
            }
            // copy chaque cell
            copyCell(oldCell, newCell, styleMap);
            CellRangeAddress mergedRegion = getMergedRegion(srcSheet, srcRow.getRowNum(),
                    (short) oldCell.getColumnIndex());

            if (mergedRegion != null) {
                // System.out.println("Selected merged region: " +
                // mergedRegion.toString());
                CellRangeAddress newMergedRegion = new CellRangeAddress(mergedRegion.getFirstRow(),
                        mergedRegion.getLastRow(), mergedRegion.getFirstColumn(), mergedRegion.getLastColumn());
                // System.out.println("New merged region: " +
                // newMergedRegion.toString());
                CellRangeAddressWrapper wrapper = new CellRangeAddressWrapper(newMergedRegion);
                if (isNewMergedRegion(wrapper, mergedRegions)) {
                    mergedRegions.add(wrapper);
                    destSheet.addMergedRegion(wrapper.range);
                }
            }
        }
    }

}

From source file:com.primovision.lutransport.service.ImportMainSheetServiceImpl.java

@Override
public List<LinkedList<Object>> importVendorSpecificFuelLog(InputStream is,
        LinkedHashMap<String, String> vendorSpecificColumns, Long vendor,
        HashMap<String, Object> additionalVendorData) throws Exception {
    List<LinkedList<Object>> data = new ArrayList<LinkedList<Object>>();
    try {/*from ww  w  .j ava2  s .c  om*/
        POIFSFileSystem fs = new POIFSFileSystem(is);

        HSSFWorkbook wb = new HSSFWorkbook(fs);
        Sheet sheet = wb.getSheetAt(0);
        Row titleRow = sheet.getRow(sheet.getFirstRowNum());

        LinkedHashMap<String, Integer> orderedColIndexes = getOrderedColumnIndexes(titleRow,
                vendorSpecificColumns);
        Set<Entry<String, Integer>> keySet = orderedColIndexes.entrySet();

        System.out.println("Physical number of rows in Excel = " + sheet.getPhysicalNumberOfRows());
        System.out.println("While reading values from vendor specific Excel Sheet: ");

        Map criterias = new HashMap();
        criterias.put("id", vendor);
        FuelVendor fuelVendor = genericDAO.findByCriteria(FuelVendor.class, criterias, "name", false).get(0);

        boolean stopParsing = false;
        for (int i = titleRow.getRowNum() + 1; !stopParsing && i <= sheet.getPhysicalNumberOfRows() - 1; i++) {
            LinkedList<Object> rowObjects = new LinkedList<Object>();

            rowObjects.add(fuelVendor.getName());
            rowObjects.add(fuelVendor.getCompany().getName());

            Row row = sheet.getRow(i);

            Iterator<Entry<String, Integer>> iterator = keySet.iterator();
            while (iterator.hasNext()) {
                Entry<String, Integer> entry = iterator.next();

                // corresponding column not found in actual column list, find in additionalVendorData
                if (entry.getValue() == -1) {
                    System.out.println("Additional vendor data = " + additionalVendorData);
                    System.out.println("Column " + entry.getKey()
                            + " not found in Vendor Excel, checking in additionalVendorData");
                    Object cellValueObj = additionalVendorData.get(entry.getKey());
                    if (cellValueObj != null) {
                        rowObjects.add(cellValueObj);
                    } else {
                        rowObjects.add(StringUtils.EMPTY);
                    }
                    continue;
                }

                Object cellValueObj = getCellValue((HSSFCell) row.getCell(entry.getValue()), true);
                if (cellValueObj != null && cellValueObj.toString().equalsIgnoreCase("END_OF_DATA")) {
                    System.out.println("Received END_OF_DATA");
                    stopParsing = true;
                    rowObjects.clear();
                    break;
                }
                rowObjects.add(cellValueObj);
            }

            if (!stopParsing) {
                data.add(rowObjects);
            }
        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

    }
    return data;
}

From source file:com.primovision.lutransport.service.ImportMainSheetServiceImpl.java

@Override
public List<LinkedList<Object>> importTollCompanySpecificTollTag(InputStream is,
        LinkedHashMap<String, String> tollCompanySpecificColumns, Long tollCompanyId) throws Exception {
    List<LinkedList<Object>> data = new ArrayList<LinkedList<Object>>();
    try {/*from w w w . ja  va  2s .c  o  m*/
        POIFSFileSystem fs = new POIFSFileSystem(is);

        HSSFWorkbook wb = new HSSFWorkbook(fs);
        Sheet sheet = wb.getSheetAt(0);
        Row titleRow = sheet.getRow(sheet.getFirstRowNum());

        LinkedHashMap<String, Integer> orderedColIndexes = getOrderedColumnIndexes(titleRow,
                tollCompanySpecificColumns);
        Set<Entry<String, Integer>> keySet = orderedColIndexes.entrySet();

        System.out.println("Physical number of rows in Excel = " + sheet.getPhysicalNumberOfRows());
        System.out.println("While reading values from vendor specific Excel Sheet: ");

        Map criterias = new HashMap();
        criterias.put("id", tollCompanyId);
        TollCompany tollCompany = genericDAO.findByCriteria(TollCompany.class, criterias, "name", false).get(0);

        //boolean stopParsing = false;
        for (int i = titleRow.getRowNum() + 1; i <= sheet.getPhysicalNumberOfRows() - 1; i++) {
            Row row = sheet.getRow(i);

            Object firstCellValueObj = getCellValue((HSSFCell) row.getCell(0), true);
            if (firstCellValueObj != null && firstCellValueObj.toString().equalsIgnoreCase("END_OF_DATA")) {
                System.out.println("Received END_OF_DATA");
                break;
            }

            LinkedList<Object> rowObjects = new LinkedList<Object>();

            rowObjects.add(tollCompany.getName());

            /*// TODO: For now, need to get logic 
            String company = StringUtils.substringAfterLast(tollCompany.getName(), " ");
            company = StringUtils.defaultIfEmpty(company, "LU");
            rowObjects.add(company);*/

            rowObjects.add(tollCompany.getCompany().getName());

            Iterator<Entry<String, Integer>> iterator = keySet.iterator();
            while (iterator.hasNext()) {
                Entry<String, Integer> entry = iterator.next();

                if (entry.getValue() == -1) {
                    // corresponding column not found
                    rowObjects.add(StringUtils.EMPTY);
                    continue;
                }

                Object cellValueObj = getCellValue((HSSFCell) row.getCell(entry.getValue()), true);
                if (cellValueObj != null) {
                    System.out.println("Adding " + cellValueObj.toString());
                } else {
                    System.out.println("Adding NULL");
                }
                rowObjects.add(cellValueObj);
            }

            data.add(rowObjects);
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return data;
}

From source file:com.projectswg.tools.SwgExcelConverter.java

License:Open Source License

public SWGFile convert(Sheet sheet) {
    Row header = sheet.getRow(sheet.getFirstRowNum());
    if (header == null)
        return null;

    int headerNum = header.getRowNum();

    // Create base datatable iff
    SWGFile swgFile = new SWGFile("DTII");
    swgFile.addForm("0001");
    // Create individual iff info
    int columns = createTableColumnData(swgFile, header);

    String[] types = createTableTypeData(swgFile, sheet.getRow(headerNum + 1), columns);
    if (types == null)
        return null;

    int rows = sheet.getPhysicalNumberOfRows();
    List<DatatableRow> rowList = new ArrayList<>();
    for (int i = headerNum + 2; i < rows; i++) {
        rowList.add(getDataTableRow(sheet.getRow(i), columns, types));
    }/*from  w  ww .java  2  s .com*/

    createTableRowData(swgFile, rowList);

    return swgFile;
}

From source file:com.projectswg.tools.SwgExcelConverter.java

License:Open Source License

private DatatableRow getDataTableRow(Row row, int expectedColumns, String[] types) {
    if (row == null || expectedColumns == 0)
        return null;

    int count = row.getPhysicalNumberOfCells();
    // Use > because empty cells are not considered a "physical cell"
    if (count > expectedColumns) {
        System.err.println("Row " + row.getRowNum() + " has " + count + " cells, expected " + expectedColumns);
        return null;
    }//from w  w  w. java 2  s.c o  m

    DatatableRow dataRow = new DatatableRow(expectedColumns);

    for (int i = 0; i < expectedColumns; i++) {
        Cell cell = row.getCell(i);
        if (cell == null) { // empty cell
            parseDataEmptyCell(types, dataRow, i);
            continue;
        }

        switch (cell.getCellType()) {
        case Cell.CELL_TYPE_STRING:
            parseDataCell(types, dataRow, i, cell.getStringCellValue());
            break;
        case Cell.CELL_TYPE_NUMERIC:
            parseDataCell(types, dataRow, i, cell.getNumericCellValue());
            break;
        default:
            System.out.println("UNK CELL TYPE: " + cell.getCellType());
        }
    }
    return dataRow;
}

From source file:com.qihang.winter.poi.excel.export.base.ExcelExportBase.java

License:Apache License

/**
 * Cell/*from  w  w  w.  ja  va  2 s  . co  m*/
 * 
 * @param patriarch
 * @param entity
 * @param row
 * @param i
 * @param imagePath
 * @param obj
 * @throws Exception
 */
public void createImageCell(Drawing patriarch,
        com.qihang.winter.poi.excel.entity.params.ExcelExportEntity entity, Row row, int i, String imagePath,
        Object obj) throws Exception {
    row.setHeight((short) (50 * entity.getHeight()));
    row.createCell(i);
    ClientAnchor anchor;
    if (type.equals(com.qihang.winter.poi.excel.entity.enmus.ExcelType.HSSF)) {
        anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) i, row.getRowNum(), (short) (i + 1),
                row.getRowNum() + 1);
    } else {
        anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) i, row.getRowNum(), (short) (i + 1),
                row.getRowNum() + 1);
    }

    if (StringUtils.isEmpty(imagePath)) {
        return;
    }
    if (entity.getExportImageType() == 1) {
        ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
        BufferedImage bufferImg;
        try {
            String path = PoiPublicUtil.getWebRootPath(imagePath);
            path = path.replace("WEB-INF/classes/", "");
            path = path.replace("file:/", "");
            bufferImg = ImageIO.read(new File(path));
            ImageIO.write(bufferImg, imagePath.substring(imagePath.indexOf(".") + 1, imagePath.length()),
                    byteArrayOut);
            byte[] value = byteArrayOut.toByteArray();
            patriarch.createPicture(anchor,
                    row.getSheet().getWorkbook().addPicture(value, getImageType(value)));
        } catch (IOException e) {
            LOGGER.error(e.getMessage(), e);
        }
    } else {
        byte[] value = (byte[]) (entity.getMethods() != null ? getFieldBySomeMethod(entity.getMethods(), obj)
                : entity.getMethod().invoke(obj, new Object[] {}));
        if (value != null) {
            patriarch.createPicture(anchor,
                    row.getSheet().getWorkbook().addPicture(value, getImageType(value)));
        }
    }

}

From source file:com.qihang.winter.poi.excel.export.base.ExcelExportBase.java

License:Apache License

/**
 * List??Cells//  ww w  .j  av  a  2 s .c  o  m
 * 
 * @param styles
 */
public void createListCells(Drawing patriarch, int index, int cellNum, Object obj,
        List<com.qihang.winter.poi.excel.entity.params.ExcelExportEntity> excelParams, Sheet sheet,
        Workbook workbook) throws Exception {
    com.qihang.winter.poi.excel.entity.params.ExcelExportEntity entity;
    Row row;
    if (sheet.getRow(index) == null) {
        row = sheet.createRow(index);
        row.setHeight(getRowHeight(excelParams));
    } else {
        row = sheet.getRow(index);
    }
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
        entity = excelParams.get(k);
        Object value = getCellValue(entity, obj);
        if (entity.getType() == 1) {
            createStringCell(row, cellNum++, value == null ? "" : value.toString(),
                    row.getRowNum() % 2 == 0 ? getStyles(false, entity) : getStyles(true, entity), entity);
        } else {
            createImageCell(patriarch, entity, row, cellNum++, value == null ? "" : value.toString(), obj);
        }
    }
}

From source file:com.qihang.winter.poi.excel.export.template.ExcelExportOfTemplateUtil.java

License:Apache License

private void parseTemplate(Sheet sheet, Map<String, Object> map) throws Exception {
    deleteCell(sheet, map);/*from   ww  w  . j  a  v  a 2 s.  c  om*/
    Row row = null;
    int index = 0;
    while (index <= sheet.getLastRowNum()) {
        row = sheet.getRow(index++);
        if (row == null) {
            continue;
        }
        for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) {
            if (row.getCell(i) != null
                    && !tempCreateCellSet.contains(row.getRowNum() + "_" + row.getCell(i).getColumnIndex())) {
                setValueForCellByMap(row.getCell(i), map);
            }
        }
    }
}