當前位置: 首頁>>代碼示例>>Java>>正文


Java HSSFSheet.getMergedRegion方法代碼示例

本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFSheet.getMergedRegion方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFSheet.getMergedRegion方法的具體用法?Java HSSFSheet.getMergedRegion怎麽用?Java HSSFSheet.getMergedRegion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.hssf.usermodel.HSSFSheet的用法示例。


在下文中一共展示了HSSFSheet.getMergedRegion方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSpan

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的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

示例2: getMergerCellRegionRow

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的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

示例3: getMergerCellRegionCol

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的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

示例4: isMergedRegion

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的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

示例5: getMergedRegion

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的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

示例6: getMergedRegionList

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的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

示例7: getMergedRegion

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的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

示例8: getMergedRegionList

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的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

示例9: getMergedRegion

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
/**
 * Récupère les informations de fusion des cellules dans la sheet source
 * pour les appliquer à la sheet destination... Récupère toutes les zones
 * merged dans la sheet source et regarde pour chacune d'elle si elle se
 * trouve dans la current row que nous traitons. Si oui, retourne l'objet
 * CellRangeAddress.
 *
 * @param sheet the sheet containing the data.
 * @param rowNum the num of the row to copy.
 * @param cellNum the num of the cell to copy.
 * @return the CellRangeAddress created.
 */
public static CellRangeAddress getMergedRegion(HSSFSheet sheet, int rowNum, short cellNum) {
    for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
        CellRangeAddress merged = sheet.getMergedRegion(i);
        if (merged.isInRange(rowNum, cellNum)) {
            return merged;
        }
    }
    return null;
}
 
開發者ID:likelet,項目名稱:DAtools,代碼行數:22,代碼來源:Util.java


注:本文中的org.apache.poi.hssf.usermodel.HSSFSheet.getMergedRegion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。