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


Java HSSFCell.setCellFormula方法代碼示例

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


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

示例1: copyCell

import org.apache.poi.hssf.usermodel.HSSFCell; //導入方法依賴的package包/類
/**
 * @param oldCell
 * @param newCell
 * @param styleMap
 */
public static void copyCell(HSSFCell oldCell, HSSFCell newCell, Map<Integer, HSSFCellStyle> styleMap) {
    if (styleMap != null) {
        if (oldCell.getSheet().getWorkbook() == newCell.getSheet().getWorkbook()) {
            newCell.setCellStyle(oldCell.getCellStyle());
        } else {
            int stHashCode = oldCell.getCellStyle().hashCode();
            HSSFCellStyle newCellStyle = styleMap.get(stHashCode);
            if (newCellStyle == null) {
                newCellStyle = newCell.getSheet().getWorkbook().createCellStyle();
                newCellStyle.cloneStyleFrom(oldCell.getCellStyle());
                styleMap.put(stHashCode, newCellStyle);
            }
            newCell.setCellStyle(newCellStyle);
        }
    }
    switch (oldCell.getCellType()) {
        case HSSFCell.CELL_TYPE_STRING:
            newCell.setCellValue(oldCell.getStringCellValue());
            break;
        case HSSFCell.CELL_TYPE_NUMERIC:
            newCell.setCellValue(oldCell.getNumericCellValue());
            break;
        case HSSFCell.CELL_TYPE_BLANK:
            newCell.setCellType(HSSFCell.CELL_TYPE_BLANK);
            break;
        case HSSFCell.CELL_TYPE_BOOLEAN:
            newCell.setCellValue(oldCell.getBooleanCellValue());
            break;
        case HSSFCell.CELL_TYPE_ERROR:
            newCell.setCellErrorValue(oldCell.getErrorCellValue());
            break;
        case HSSFCell.CELL_TYPE_FORMULA:
            newCell.setCellFormula(oldCell.getCellFormula());
            break;
        default:
            break;
    }

}
 
開發者ID:likelet,項目名稱:DAtools,代碼行數:45,代碼來源:Util.java

示例2: copyCell

import org.apache.poi.hssf.usermodel.HSSFCell; //導入方法依賴的package包/類
public static void copyCell(HSSFCell oldCell, HSSFCell newCell, Map<Integer, HSSFCellStyle> styleMap) {  
    if(styleMap != null) {  
        if(oldCell.getSheet().getWorkbook() == newCell.getSheet().getWorkbook()){  
            newCell.setCellStyle(oldCell.getCellStyle());  
        } else{  
            int stHashCode = oldCell.getCellStyle().hashCode();  
            HSSFCellStyle newCellStyle = styleMap.get(stHashCode);  
            if(newCellStyle == null){  
                newCellStyle = newCell.getSheet().getWorkbook().createCellStyle();  
                newCellStyle.cloneStyleFrom(oldCell.getCellStyle());  
                styleMap.put(stHashCode, newCellStyle);  
            }  
            newCell.setCellStyle(newCellStyle);  
        }  
    }  
    switch(oldCell.getCellType()) {  
        case HSSFCell.CELL_TYPE_STRING:  
            newCell.setCellValue(oldCell.getStringCellValue());  
            break;  
        case HSSFCell.CELL_TYPE_NUMERIC:  
            newCell.setCellValue(oldCell.getNumericCellValue());  
            break;  
        case HSSFCell.CELL_TYPE_BLANK:  
            newCell.setCellType(HSSFCell.CELL_TYPE_BLANK);  
            break;  
        case HSSFCell.CELL_TYPE_BOOLEAN:  
            newCell.setCellValue(oldCell.getBooleanCellValue());  
            break;  
        case HSSFCell.CELL_TYPE_ERROR:  
            newCell.setCellErrorValue(oldCell.getErrorCellValue());  
            break;  
        case HSSFCell.CELL_TYPE_FORMULA:  
            newCell.setCellFormula(oldCell.getCellFormula());  
            break;  
        default:  
            break;  
    }  
      
}
 
開發者ID:rmage,項目名稱:gnvc-ims,代碼行數:40,代碼來源:MultiPageReportModel.java

示例3: copyRow

import org.apache.poi.hssf.usermodel.HSSFCell; //導入方法依賴的package包/類
public static void copyRow(final HSSFSheet oldSheet, final HSSFSheet newSheet, final int oldRowNum, final int newRowNum) {
    final HSSFRow oldRow = oldSheet.getRow(oldRowNum);

    final HSSFRow newRow = newSheet.createRow(newRowNum);

    if (oldRow == null) {
        return;
    }

    newRow.setHeight(oldRow.getHeight());

    if (oldRow.getFirstCellNum() == -1) {
        return;
    }

    for (int colNum = oldRow.getFirstCellNum(); colNum <= oldRow.getLastCellNum(); colNum++) {
        final HSSFCell oldCell = oldRow.getCell(colNum);
        final HSSFCell newCell = newRow.createCell(colNum);

        if (oldCell != null) {
            final HSSFCellStyle style = oldCell.getCellStyle();
            newCell.setCellStyle(style);

            final int cellType = oldCell.getCellType();
            newCell.setCellType(cellType);

            if (cellType == Cell.CELL_TYPE_BOOLEAN) {
                newCell.setCellValue(oldCell.getBooleanCellValue());

            } else if (cellType == Cell.CELL_TYPE_FORMULA) {
                newCell.setCellFormula(oldCell.getCellFormula());

            } else if (cellType == Cell.CELL_TYPE_NUMERIC) {
                newCell.setCellValue(oldCell.getNumericCellValue());

            } else if (cellType == Cell.CELL_TYPE_STRING) {
                newCell.setCellValue(oldCell.getRichStringCellValue());
            }
        }
    }

    POIUtils.copyMergedRegion(newSheet, getMergedRegionList(oldSheet, oldRowNum), newRowNum);
}
 
開發者ID:roundrop,項目名稱:ermasterr,代碼行數:44,代碼來源:POIUtils.java

示例4: copyRow

import org.apache.poi.hssf.usermodel.HSSFCell; //導入方法依賴的package包/類
public static void copyRow(HSSFSheet oldSheet, HSSFSheet newSheet,
		int oldRowNum, int newRowNum) {
	HSSFRow oldRow = oldSheet.getRow(oldRowNum);

	HSSFRow newRow = newSheet.createRow(newRowNum);

	if (oldRow == null) {
		return;
	}

	newRow.setHeight(oldRow.getHeight());

	if (oldRow.getFirstCellNum() == -1) {
		return;
	}

	for (int colNum = oldRow.getFirstCellNum(); colNum <= oldRow
			.getLastCellNum(); colNum++) {
		HSSFCell oldCell = oldRow.getCell(colNum);
		HSSFCell newCell = newRow.createCell(colNum);

		if (oldCell != null) {
			HSSFCellStyle style = oldCell.getCellStyle();
			newCell.setCellStyle(style);

			int cellType = oldCell.getCellType();
			newCell.setCellType(cellType);

			if (cellType == HSSFCell.CELL_TYPE_BOOLEAN) {
				newCell.setCellValue(oldCell.getBooleanCellValue());

			} else if (cellType == HSSFCell.CELL_TYPE_FORMULA) {
				newCell.setCellFormula(oldCell.getCellFormula());

			} else if (cellType == HSSFCell.CELL_TYPE_NUMERIC) {
				newCell.setCellValue(oldCell.getNumericCellValue());

			} else if (cellType == HSSFCell.CELL_TYPE_STRING) {
				newCell.setCellValue(oldCell.getRichStringCellValue());
			}
		}
	}

	POIUtils.copyMergedRegion(newSheet,
			getMergedRegionList(oldSheet, oldRowNum), newRowNum);
}
 
開發者ID:kozake,項目名稱:ermaster-k,代碼行數:47,代碼來源:POIUtils.java


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