本文整理了Java中org.apache.poi.ss.usermodel.Cell.getCellFormula()
方法的一些代码示例,展示了Cell.getCellFormula()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cell.getCellFormula()
方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Cell
类名称:Cell
方法名:getCellFormula
[英]Return a formula for the cell, for example, SUM(C4:E4)
[中]返回单元格的公式,例如,SUM(C4:E4)
代码示例来源:origin: stackoverflow.com
for(Cell cell : row) {
if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
System.out.println("Formula is " + cell.getCellFormula());
switch(cell.getCachedFormulaResultType()) {
case Cell.CELL_TYPE_NUMERIC:
System.out.println("Last evaluated as: " + cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_STRING:
System.out.println("Last evaluated as \"" + cell.getRichStringCellValue() + "\"");
break;
}
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
outputQuotedString(cell.getCellFormula());
_out.write("</f>");
switch (cell.getCachedFormulaResultType()) {
代码示例来源:origin: org.apache.poi/poi-ooxml
protected void adjustCellReferencesInsideFormula(Cell cell, Sheet destSheet, int deltaX, int deltaY){
XSSFWorkbook hostWorkbook = (XSSFWorkbook) destSheet.getWorkbook();
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(hostWorkbook);
Ptg[] ptgs = FormulaParser.parse(cell.getCellFormula(), fpb, FormulaType.CELL, 0);
int destSheetIndex = hostWorkbook.getSheetIndex(destSheet);
if(adjustInBothDirections(ptgs, destSheetIndex, deltaX, deltaY))
cell.setCellFormula(FormulaRenderer.toFormulaString(fpb, ptgs));
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
String contents = cell.getCellFormula();
checkMaxTextSize(text, contents);
text.append(contents);
代码示例来源:origin: org.apache.poi/poi
break;
case FORMULA:
String oldFormula = srcCell.getCellFormula();
destCell.setCellFormula(oldFormula);
break;
代码示例来源:origin: org.apache.poi/poi
if (cellType == CellType.FORMULA) {
if (evaluator == null) {
return cell.getCellFormula();
代码示例来源:origin: org.apache.poi/poi-ooxml
break;
case FORMULA:
setCellFormula(srcCell.getCellFormula());
break;
case BLANK:
代码示例来源:origin: org.apache.poi/poi-examples
/**
* Checks if cell content matches for formula.
*/
private void isCellContentMatchesForFormula(Locator loc1, Locator loc2) {
// TODO: actually evaluate the formula / NPE checks
String form1 = loc1.cell.getCellFormula();
String form2 = loc2.cell.getCellFormula();
if (!form1.equals(form2)) {
addMessage(loc1, loc2, CELL_DATA_DOES_NOT_MATCH, form1, form2);
}
}
代码示例来源:origin: com.phloc/phloc-poi
@Nullable
public static String getCellFormula (@Nullable final Cell aCell)
{
if (aCell != null)
try
{
return aCell.getCellFormula ();
}
catch (final RuntimeException ex)
{
// fall through
s_aLogger.warn ("Failed to get cell formula: " + ex.getMessage ());
}
return null;
}
代码示例来源:origin: com.helger/ph-poi
@Nullable
public static String getCellFormula (@Nullable final Cell aCell)
{
if (aCell != null)
try
{
return aCell.getCellFormula ();
}
catch (final RuntimeException ex)
{
// fall through
LOGGER.warn ("Failed to get cell formula: " + ex.getMessage ());
}
return null;
}
代码示例来源:origin: com.hand/hap-core-db
public TD(Cell cell, TR tr, COL col) {
this.tr = tr;
this.col = col;
this.cell = cell;
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
isFormula = true;
formula = cell.getCellFormula().replace("$", "");
valuePresent = false;
}
if (col.gen) {
valuePresent = false;
}
}
代码示例来源:origin: com.hand/hap-db
public TD(Cell cell, TR tr, COL col) {
this.tr = tr;
this.col = col;
this.cell = cell;
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
isFormula = true;
formula = cell.getCellFormula().replace("$", "");
valuePresent = false;
}
if (col.gen) {
valuePresent = false;
}
}
代码示例来源:origin: stackoverflow.com
public static void copyCellFormula(Workbook workbook, int sheetIndex, int rowIndex, int sourceColumnIndex, int destinationColumnIndex){
XSSFEvaluationWorkbook formulaParsingWorkbook = XSSFEvaluationWorkbook.create((XSSFWorkbook) workbook);
SharedFormula sharedFormula = new SharedFormula(SpreadsheetVersion.EXCEL2007);
Sheet sheet = workbook.getSheetAt(sheetIndex);
Row lookupRow = sheet.getRow(rowIndex);
Cell sourceCell = lookupRow.getCell(sourceColumnIndex);
Ptg[] sharedFormulaPtg = FormulaParser.parse(sourceCell.getCellFormula(), formulaParsingWorkbook, FormulaType.CELL, sheetIndex);
Ptg[] convertedFormulaPtg = sharedFormula.convertSharedFormulas(sharedFormulaPtg, 0, 1);
Cell destinationCell = lookupRow.createCell(destinationColumnIndex);
destinationCell.setCellFormula(FormulaRenderer.toFormulaString(formulaParsingWorkbook, convertedFormulaPtg));
}
代码示例来源:origin: openl-tablets/openl-tablets
@SuppressWarnings("deprecation")
@Override
public String getFormula(int row, int column) {
Cell cell = getCell(row, column);
return cell.getCellType() == CellType.FORMULA ? cell.getCellFormula() : null;
}
代码示例来源:origin: com.qaprosoft/carina-dataprovider
public static String getCellValue(Cell cell) {
if (cell == null)
return "";
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
return df.formatCellValue(cell).trim();
case Cell.CELL_TYPE_NUMERIC:
return df.formatCellValue(cell).trim();
case Cell.CELL_TYPE_BOOLEAN:
return df.formatCellValue(cell).trim();
case Cell.CELL_TYPE_FORMULA:
return (cell.getCellFormula().contains("[") && cell.getCellFormula().contains("]")) ? null : df.formatCellValue(cell, evaluator).trim();
case Cell.CELL_TYPE_BLANK:
return "";
default:
return null;
}
}
代码示例来源:origin: openl-tablets/openl-tablets
private String cellFormula() {
Cell cell = getCell();
return cell.getCellType() == CellType.FORMULA ? cell.getCellFormula() : null;
}
代码示例来源:origin: stackoverflow.com
CellReference cellReference = new CellReference("B3");
Row row = sheet.getRow(cellReference.getRow());
Cell cell = row.getCell(cellReference.getCol());
String formula = cell.getCellFormula();
代码示例来源:origin: net.guerlab/azeroth
private static String getStringValue(
Cell cell,
DecimalFormat decimalFormat) {
switch (cell.getCellTypeEnum()) {
case NUMERIC:
return getNumberTypeStringValue(cell, decimalFormat);
case STRING:
return cell.getStringCellValue();
case FORMULA:
return cell.getCellFormula();
case BOOLEAN:
return String.valueOf(cell.getBooleanCellValue());
default:
return "";
}
}
代码示例来源:origin: tobyweston/simple-excel
@Override
public Cell adapt(org.apache.poi.ss.usermodel.Cell cell) {
if (cell.getCachedFormulaResultType() == CELL_TYPE_ERROR)
return new ErrorCell(cell.getErrorCellValue());
return new FormulaCell(cell.getCellFormula());
}
},
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
protected void adjustCellReferencesInsideFormula(Cell cell, Sheet destSheet, int deltaX, int deltaY){
XSSFWorkbook hostWorkbook = (XSSFWorkbook) destSheet.getWorkbook();
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(hostWorkbook);
Ptg[] ptgs = FormulaParser.parse(cell.getCellFormula(), fpb, FormulaType.CELL, 0);
int destSheetIndex = hostWorkbook.getSheetIndex(destSheet);
if(adjustInBothDirections(ptgs, destSheetIndex, deltaX, deltaY))
cell.setCellFormula(FormulaRenderer.toFormulaString(fpb, ptgs));
}
}
内容来源于网络,如有侵权,请联系作者删除!