当前位置: 首页>>代码示例>>Java>>正文


Java CellRangeAddress.getFirstRow方法代码示例

本文整理汇总了Java中org.apache.poi.ss.util.CellRangeAddress.getFirstRow方法的典型用法代码示例。如果您正苦于以下问题:Java CellRangeAddress.getFirstRow方法的具体用法?Java CellRangeAddress.getFirstRow怎么用?Java CellRangeAddress.getFirstRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.ss.util.CellRangeAddress的用法示例。


在下文中一共展示了CellRangeAddress.getFirstRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMergerCellRegionRow

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
/**
 * 判断单元格是否是合并的单格,如果是,获取其合并的行数。
 */
private static int getMergerCellRegionRow(HSSFSheet sheet, int cellRow, int cellCol) throws Throwable {
	int retVal = 0;
	int sheetMergerCount = sheet.getNumMergedRegions();
	for (int i = 0; i < sheetMergerCount; i++) {
		CellRangeAddress cra = sheet.getMergedRegion(i);
		int firstRow = cra.getFirstRow(); // 合并单元格CELL起始行
		int firstCol = cra.getFirstColumn(); // 合并单元格CELL起始列
		int lastRow = cra.getLastRow(); // 合并单元格CELL结束行
		int lastCol = cra.getLastColumn(); // 合并单元格CELL结束列
		if (cellRow >= firstRow && cellRow <= lastRow) { // 判断该单元格是否是在合并单元格中
			if (cellCol >= firstCol && cellCol <= lastCol) {
				retVal = lastRow - firstRow + 1; // 得到合并的行数
				break;
			}
		}
	}
	return retVal;
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:22,代码来源:OfficeConverter.java

示例2: getSpan

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
private Span getSpan(XSSFSheet sheet,int row ,int column){
	int sheetMergeCount = sheet.getNumMergedRegions(); 
	for (int i = 0; i < sheetMergeCount; i++) {
		CellRangeAddress range = sheet.getMergedRegion(i);
		int firstColumn = range.getFirstColumn();
		int lastColumn = range.getLastColumn();
		int firstRow = range.getFirstRow();
		if(row == firstRow && column==firstColumn){  
			int lastRow = range.getLastRow();
			int rowSpan=lastRow-firstRow;
			if(rowSpan>0){
				rowSpan++;
			}
			int colSpan=lastColumn-firstColumn;
			if(colSpan>0){
				colSpan++;
			}
			return new Span(rowSpan,colSpan);
		}
	}
	return new Span(0,0);
}
 
开发者ID:youseries,项目名称:ureport,代码行数:23,代码来源:XSSFExcelParser.java

示例3: isMergedRegion

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
private boolean isMergedRegion(XSSFSheet sheet, int row, int column) {
	int sheetMergeCount = sheet.getNumMergedRegions();
	for (int i = 0; i < sheetMergeCount; i++) {
		CellRangeAddress range = sheet.getMergedRegion(i);
		int firstColumn = range.getFirstColumn();
		int lastColumn = range.getLastColumn();
		int firstRow = range.getFirstRow();
		int lastRow = range.getLastRow();
		if (row > firstRow && row < lastRow) {
			if (column > firstColumn && column < lastColumn) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:youseries,项目名称:ureport,代码行数:17,代码来源:XSSFExcelParser.java

示例4: getMergerCellRegionCol

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
/**
 * 判断单元格在不在合并单元格范围内,如果是,获取其合并的列数。
 */
private static int getMergerCellRegionCol(HSSFSheet sheet, int cellRow, int cellCol) throws Throwable {
	int retVal = 0;
	int sheetMergerCount = sheet.getNumMergedRegions();
	for (int i = 0; i < sheetMergerCount; i++) {
		CellRangeAddress cra = sheet.getMergedRegion(i);
		int firstRow = cra.getFirstRow(); // 合并单元格CELL起始行
		int firstCol = cra.getFirstColumn(); // 合并单元格CELL起始列
		int lastRow = cra.getLastRow(); // 合并单元格CELL结束行
		int lastCol = cra.getLastColumn(); // 合并单元格CELL结束列
		if (cellRow >= firstRow && cellRow <= lastRow) { // 判断该单元格是否是在合并单元格中
			if (cellCol >= firstCol && cellCol <= lastCol) {
				retVal = lastCol - firstCol + 1; // 得到合并的列数
				break;
			}
		}
	}
	return retVal;
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:22,代码来源:OfficeConverter.java

示例5: getSpan

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
private Span getSpan(HSSFSheet sheet,int row ,int column){
	int sheetMergeCount = sheet.getNumMergedRegions(); 
	for (int i = 0; i < sheetMergeCount; i++) {
		CellRangeAddress range = sheet.getMergedRegion(i);
		int firstColumn = range.getFirstColumn();
		int lastColumn = range.getLastColumn();
		int firstRow = range.getFirstRow();
		if(row == firstRow && column==firstColumn){  
			int lastRow = range.getLastRow();
			int rowSpan=lastRow-firstRow;
			if(rowSpan>0){
				rowSpan++;
			}
			int colSpan=lastColumn-firstColumn;
			if(colSpan>0){
				colSpan++;
			}
			return new Span(rowSpan,colSpan);
		}
	}
	return new Span(0,0);
}
 
开发者ID:youseries,项目名称:ureport,代码行数:23,代码来源:HSSFExcelParser.java

示例6: isMergedRegion

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
private boolean isMergedRegion(HSSFSheet sheet, int row, int column) {
	int sheetMergeCount = sheet.getNumMergedRegions();
	for (int i = 0; i < sheetMergeCount; i++) {
		CellRangeAddress range = sheet.getMergedRegion(i);
		int firstColumn = range.getFirstColumn();
		int lastColumn = range.getLastColumn();
		int firstRow = range.getFirstRow();
		int lastRow = range.getLastRow();
		if (row > firstRow && row < lastRow) {
			if (column > firstColumn && column < lastColumn) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:youseries,项目名称:ureport,代码行数:17,代码来源:HSSFExcelParser.java

示例7: copyRow

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
/**
 * @param srcSheet 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(XSSFSheet srcSheet, XSSFSheet destSheet, XSSFRow srcRow, XSSFRow destRow, Map<Integer, XSSFCellStyle> 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++) {
        if(j<0){
        }else{
            XSSFCell oldCell = srcRow.getCell(j);   // ancienne cell  
        XSSFCell newCell = destRow.getCell(j);  // new cell   
        if (oldCell != null) {
            if (newCell == null) {
                newCell = destRow.createCell(j);
            }
            // copy chaque cell  
            copyCell(oldCell, newCell, styleMap);
                  // copy les informations de fusion entre les cellules  
            //System.out.println("row num: " + srcRow.getRowNum() + " , col: " + (short)oldCell.getColumnIndex());  
            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);
                }
            }
        }
        }
        
    }

}
 
开发者ID:likelet,项目名称:DAtools,代码行数:44,代码来源:Util.java

示例8: getMergedRegionValue

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
/**  
 * 获取合并单元格的值  
 * @param sheet  
 * @param row  
 * @param column  
 * @return  
 */
public static String getMergedRegionValue(Sheet sheet, int row, int column) {
    int sheetMergeCount = sheet.getNumMergedRegions();

    for (int i = 0; i < sheetMergeCount; i++) {
        CellRangeAddress ca = sheet.getMergedRegion(i);
        int firstColumn = ca.getFirstColumn();
        int lastColumn = ca.getLastColumn();
        int firstRow = ca.getFirstRow();
        int lastRow = ca.getLastRow();

        if (row >= firstRow && row <= lastRow) {

            if (column >= firstColumn && column <= lastColumn) {
                Row fRow = sheet.getRow(firstRow);
                Cell fCell = fRow.getCell(firstColumn);

                return getCellValue(fCell);
            }
        }
    }

    return null;
}
 
开发者ID:rushingpig,项目名称:poix,代码行数:31,代码来源:PoiCellUtil.java

示例9: isMergedRegion

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
/**  
 * 判断指定的单元格是否是合并单元格  
 * @param sheet  
 * @param row  
 * @param column  
 * @return  
 */
public static boolean isMergedRegion(Sheet sheet, int row, int column) {
    int sheetMergeCount = sheet.getNumMergedRegions();

    for (int i = 0; i < sheetMergeCount; i++) {
        CellRangeAddress ca = sheet.getMergedRegion(i);
        int firstColumn = ca.getFirstColumn();
        int lastColumn = ca.getLastColumn();
        int firstRow = ca.getFirstRow();
        int lastRow = ca.getLastRow();

        if (row >= firstRow && row <= lastRow) {
            if (column >= firstColumn && column <= lastColumn) {

                return true;
            }
        }
    }

    return false;
}
 
开发者ID:rushingpig,项目名称:poix,代码行数:28,代码来源:PoiCellUtil.java

示例10: getMergedRegion

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
public static CellRangeAddress getMergedRegion(final HSSFSheet sheet, final CellLocation location) {
    for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
        final CellRangeAddress region = sheet.getMergedRegion(i);

        final int rowFrom = region.getFirstRow();
        final int rowTo = region.getLastRow();

        if (rowFrom == location.r && rowTo == location.r) {
            final int colFrom = region.getFirstColumn();

            if (colFrom == location.c) {
                return region;
            }
        }
    }

    return null;
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:19,代码来源:POIUtils.java

示例11: getMergedRegionList

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
public static List<CellRangeAddress> getMergedRegionList(final HSSFSheet sheet, final int rowNum) {
    final List<CellRangeAddress> regionList = new ArrayList<CellRangeAddress>();

    for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
        final CellRangeAddress region = sheet.getMergedRegion(i);

        final int rowFrom = region.getFirstRow();
        final int rowTo = region.getLastRow();

        if (rowFrom == rowNum && rowTo == rowNum) {
            regionList.add(region);
        }
    }

    return regionList;
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:17,代码来源:POIUtils.java

示例12: copyRows

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
/**
 * 指定範囲の行をコピーします。
 * @param sheet シート。
 * @param from コピー元。
 * @param rows コピー行数。
 * @param to コピー先。
 */
private void copyRows(final Sheet sheet, final int from, final int rows, final int to) {
	for (int i = from; i < rows; i++) {
		this.copyRow(sheet, from + i,  to + i);
	}
	// 結合情報をコピーする。
	int cnt = sheet.getNumMergedRegions();
	for (int i = 0; i < cnt; i++) {
		CellRangeAddress cra = sheet.getMergedRegion(i);
		if (from <= cra.getFirstRow() && cra.getFirstRow() < from + rows) {
			cra.setFirstRow(cra.getFirstRow() + to);
			cra.setLastRow(cra.getLastRow() + to);
			sheet.addMergedRegion(cra);
		}
	}
}
 
开发者ID:takayanagi2087,项目名称:dataforms,代码行数:23,代码来源:ExcelReport.java

示例13: getMergedRegion

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
public static CellRangeAddress getMergedRegion(HSSFSheet sheet,
		CellLocation location) {
	for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
		CellRangeAddress region = sheet.getMergedRegion(i);

		int rowFrom = region.getFirstRow();
		int rowTo = region.getLastRow();

		if (rowFrom == location.r && rowTo == location.r) {
			int colFrom = region.getFirstColumn();

			if (colFrom == location.c) {
				return region;
			}
		}
	}

	return null;
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:20,代码来源:POIUtils.java

示例14: getMergedRegionList

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
public static List<CellRangeAddress> getMergedRegionList(HSSFSheet sheet,
		int rowNum) {
	List<CellRangeAddress> regionList = new ArrayList<CellRangeAddress>();

	for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
		CellRangeAddress region = sheet.getMergedRegion(i);

		int rowFrom = region.getFirstRow();
		int rowTo = region.getLastRow();

		if (rowFrom == rowNum && rowTo == rowNum) {
			regionList.add(region);
		}
	}

	return regionList;
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:18,代码来源:POIUtils.java

示例15: A1RangeAddress

import org.apache.poi.ss.util.CellRangeAddress; //导入方法依赖的package包/类
protected A1RangeAddress(String a1address) {
    this.addresses = new LinkedList<>();
    
    if (!a1address.contains(RANGE_DELIMITER)) { this.addresses.add(A1Address.fromA1Address(a1address)); return; }
    
    CellRangeAddress addrs = CellRangeAddress.valueOf(a1address);
    int fromR = addrs.getFirstRow();
    int fromC = addrs.getFirstColumn();
    int toR = addrs.getLastRow();
    int toC = addrs.getLastColumn();

    for (int row = fromR; row <= toR; row++) {
        for (int col = fromC; col <= toC; col++) {
            this.addresses.add(A1Address.fromRowColumn(row, col));
        }
    }
}
 
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:18,代码来源:A1RangeAddress.java


注:本文中的org.apache.poi.ss.util.CellRangeAddress.getFirstRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。