本文整理汇总了Java中org.apache.poi.hssf.model.HSSFFormulaParser类的典型用法代码示例。如果您正苦于以下问题:Java HSSFFormulaParser类的具体用法?Java HSSFFormulaParser怎么用?Java HSSFFormulaParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HSSFFormulaParser类属于org.apache.poi.hssf.model包,在下文中一共展示了HSSFFormulaParser类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateFormulas
import org.apache.poi.hssf.model.HSSFFormulaParser; //导入依赖的package包/类
protected void updateFormulas(Area templateArea, Area dependentResultArea) {
HSSFSheet templateSheet = getTemplateSheetForRangeName(templateWorkbook, templateArea.getName());
HSSFSheet resultSheet = templateToResultSheetsMapping.get(templateSheet);
AreaReference area = dependentResultArea.toAreaReference();
for (CellReference cell : area.getAllReferencedCells()) {
HSSFCell resultCell = getCellFromReference(cell, resultSheet);
if (resultCell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
Ptg[] ptgs = HSSFFormulaParser.parse(resultCell.getCellFormula(), resultWorkbook);
for (Ptg ptg : ptgs) {
if (ptg instanceof AreaPtg) {
areaDependencyManager.updateAreaPtg(templateArea, dependentResultArea, (AreaPtg) ptg);
} else if (ptg instanceof RefPtg) {
areaDependencyManager.updateRefPtg(templateArea, dependentResultArea, (RefPtg) ptg);
}
}
String calculatedFormula = HSSFFormulaParser.toFormulaString(templateWorkbook, ptgs);
resultCell.setCellFormula(calculatedFormula);
}
}
}