zoukankan      html  css  js  c++  java
  • 获取合并单元格中值的一个方法POI

        private static String getCellValueForMerginRegion(Cell cell) {
            
            int rowIdx=cell.getRowIndex();
            Sheet sheet=cell.getSheet();
            int mergedRegions=sheet.getNumMergedRegions();
            for (int i = 0; i < mergedRegions; i++) {
                CellRangeAddress cellRangeAddress=sheet.getMergedRegion(i);
                
                if (cellRangeAddress.getLastColumn()==0) {
                    int firstRowIdx=cellRangeAddress.getFirstRow();
                    int lastRowIdx=cellRangeAddress.getLastRow();
                    if (rowIdx<=lastRowIdx&&rowIdx>=firstRowIdx) {
                        String cellValue = null;
                        for (int j = firstRowIdx; j <=lastRowIdx; j++) {
                            cellValue=getCellValue(sheet.getRow(j).getCell(0));
                            if (cellValue.trim().length()==0) {
                                System.out.println("firstRowIdx:"+firstRowIdx+",lastRowIdx:"+lastRowIdx+":"+cellValue);
                                continue;
                            }
                            break;
                        }
                        
                        return cellValue;
                    }
                }
                
                
            }
            
            
            return null;
        }
  • 相关阅读:
    多层交换概述
    多层交换MLS笔记2
    多层交换MLS笔记1
    RSTP Proposal-Agreement
    RSTP Note
    保护STP
    优化STP
    Cisco STP Note
    25、C++的顶层const和底层const
    43、如何用代码判断大小端存储
  • 原文地址:https://www.cnblogs.com/softidea/p/4249608.html
Copyright © 2011-2022 走看看