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


Java FormulaParseException类代码示例

本文整理汇总了Java中org.apache.poi.ss.formula.FormulaParseException的典型用法代码示例。如果您正苦于以下问题:Java FormulaParseException类的具体用法?Java FormulaParseException怎么用?Java FormulaParseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FormulaParseException类属于org.apache.poi.ss.formula包,在下文中一共展示了FormulaParseException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createName

import org.apache.poi.ss.formula.FormulaParseException; //导入依赖的package包/类
protected void createName(HandlerState state, String bookmark, int row1, int col1, int row2, int col2 ) {
	CellReference crFirst = new CellReference( state.currentSheet.getSheetName(), row1, col1, true, true );
	CellReference crLast = new CellReference( row2, col2, true, true );
	String formula = crFirst.formatAsString() + ":" + crLast.formatAsString();

	Name name = state.currentSheet.getWorkbook().getName(bookmark);
	if( name == null ) {
		name = state.currentSheet.getWorkbook().createName();
		name.setNameName( bookmark ); 
		name.setRefersToFormula( formula );
	} else {
		String existingFormula = name.getRefersToFormula();
		try {
			name.setRefersToFormula(existingFormula + "," + formula);
		} catch( FormulaParseException ex ) {
			log.warn( 0, "Unable to add \"" + formula + "\" to name (\"" + bookmark + "\") with existing formula: " + existingFormula, ex );
		}
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:20,代码来源:AbstractHandler.java

示例2: toDataModels

import org.apache.poi.ss.formula.FormulaParseException; //导入依赖的package包/类
/**
 * Extracts {@link IDataModel} from {@link Workbook} for given function name.
 * Useful for formula with particular functions. Does scan IDataModel for exact formula use and create new 
 * {@link IDataModel} for every formula found.
 */
static List<IDataModel> toDataModels(final Workbook book, final String function) {
    if (book == null || function == null) { return emptyList(); }
    List<IDataModel> list = new LinkedList<>();

    final FormulaParsingWorkbook parsingBook = create((XSSFWorkbook) book);
    
    Sheet s = book.getSheetAt(0); /* TODO: only one sheet is supported */
    for (Row r : s) {
        for (Cell c : r) {
            if (c == null || CELL_TYPE_FORMULA != c.getCellType()) { continue; }

            try {
                if (ConverterUtils.isFunctionInFormula(c.getCellFormula(), function))
                    { list.add(createDataModelFromCell(s, parsingBook, fromRowColumn(c.getRowIndex(), c.getColumnIndex()))); } }
            catch (FormulaParseException e) { log.warn("Warning while parsing excel formula. Probably this is OK.", e); }
        }
    }
    
    return list;
}
 
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:26,代码来源:DependencyExtractors.java

示例3: setupCellFormula

import org.apache.poi.ss.formula.FormulaParseException; //导入依赖的package包/类
/**
 * セルに数式を設定する。
 * @since 1.5
 * 
 * @param adaptor フィールド
 * @param formulaAnno 数式定義用のアノテーション。
 * @param config システム設定。
 * @param cell 設定対象のセル。
 * @param targetBean 処理対象のJavaBean.
 * @throws XlsMapperException
 */
public static void setupCellFormula(final FieldAdaptor adaptor, final XlsFormula formulaAnno, final XlsMapperConfig config, 
        final Cell cell, final Object targetBean) throws XlsMapperException {
    
    ArgUtils.notNull(adaptor, "adaptor");
    ArgUtils.notNull(formulaAnno, "formulaAnno");
    ArgUtils.notNull(config, "config");
    ArgUtils.notNull(cell, "cell");
    
    final String formula = getFormulaValue(adaptor, formulaAnno, config, cell, targetBean);
    if(isEmpty(formula)) {
        cell.setCellType(Cell.CELL_TYPE_BLANK);
        return;
    }
    
    try {
        cell.setCellFormula(formula);
        cell.setCellType(Cell.CELL_TYPE_FORMULA);
        
    } catch(FormulaParseException e) {
        // 数式の解析に失敗した場合
        final String message = new StringBuilder()
                .append(String.format("Fail parse formula '%s'.", formula))
                .append(String.format(" Cell '%s' map from '%s#%s'.", 
                        formatCellAddress(cell), adaptor.getDeclaringClass().getName(), adaptor.getName()))
                .toString();
            
        throw new ConversionException(message, e, adaptor.getTargetClass());
    }
}
 
开发者ID:mygreen,项目名称:xlsmapper,代码行数:41,代码来源:Utils.java

示例4: setCellSubtitle

import org.apache.poi.ss.formula.FormulaParseException; //导入依赖的package包/类
public void setCellSubtitle(int row, int column, String location, String strTo, String strFrom) throws FormulaParseException, Exception {
	String subTitle = "SUBSTITUTE(PROPER(" + location + ")," + strTo + "," + strFrom + ")";
	this.getCell(row, column).setCellFormula(subTitle);
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:5,代码来源:SheetVO.java

示例5: buildExecutionGraph

import org.apache.poi.ss.formula.FormulaParseException; //导入依赖的package包/类
@Override
public IExecutionGraph buildExecutionGraph(IA1Address cell, ExecutionGraphConfig config) {
    try {
        this.graphLock.lock();
        log.debug("Building Graph for address: {}.", cell);
        
        /* Clear POI cache to allow graph building to be full */
        this.evaluator.poiEvaluator.clearAllCachedResultValues();
                    
        PoiExecutionGraphBuilder graphBuilder = new PoiExecutionGraphBuilder(config);
        this.evaluator.setExecutionGraphBuilder(graphBuilder);
        
        try {
            IEvaluationResult<ICellValue> res = this.evaluator.evaluate(cell);
            
            if (res == null || res.getResult() == null || res.getResult().get() == null) 
                { return buildSingleVertexGraphForEmptyCell(cell); }

            ICellValue cv = res.getResult();
            
            graphBuilder.runPostProcessing(false);
            ExecutionGraph g = graphBuilder.getGraph();
            
            if (g.getVertices().isEmpty()) { return buildSingleVertexGraphForCellWithValue(cv, new CellAddress(this.evaluator.model.getDataModelId(), cell)); }
            if (g.getVertices().size() == 1) {
                if (VALUE_INVALID.getErrorString().equals(cv.get()))
                    { return buildSingleVertexGraphForParseException(new CellAddress(this.evaluator.model.getDataModelId(), cell), VALUE_INVALID, null); }
                if (NAME_INVALID.getErrorString().equals(cv.get()))
                    { return buildSingleVertexGraphForParseException(new CellAddress(this.evaluator.model.getDataModelId(), cell), NAME_INVALID, null); }
            }
            
            return g;
        } catch (FormulaParseException | IncorrectExternalReferenceException e) {
            log.warn("Caught exception while building a graph, but the graph should be ok.", e);
            return graphBuilder.getGraph();
        }
    } finally {
        this.graphLock.unlock();
        log.debug("Building Graph for address: {} is finished.", cell);
    }
}
 
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:42,代码来源:SpreadsheetAuditor.java

示例6: isFormula

import org.apache.poi.ss.formula.FormulaParseException; //导入依赖的package包/类
/** Returns true if value string is formula */
static boolean isFormula(String value, EvaluationWorkbook workbook) {
    try { return FormulaParser.parse(value, (FormulaParsingWorkbook) workbook, 0, 0).length > 1; } // TODO: formulaType and sheet index are 0
    catch (FormulaParseException e) { return false; }
}
 
开发者ID:DataArt,项目名称:CalculationEngine,代码行数:6,代码来源:ConverterUtils.java

示例7: setCellFormula

import org.apache.poi.ss.formula.FormulaParseException; //导入依赖的package包/类
public void setCellFormula(String formula) throws FormulaParseException {
	throw new IllegalStateException("CellClone is not support setCellFormula(String formula).");
}
 
开发者ID:excella-core,项目名称:excella-core,代码行数:4,代码来源:CellClone.java

示例8: setCellFormula

import org.apache.poi.ss.formula.FormulaParseException; //导入依赖的package包/类
/**
 * Not supported
 */
@Override
public void setCellFormula(String formula) throws FormulaParseException {
  throw new NotSupportedException();
}
 
开发者ID:monitorjbl,项目名称:excel-streaming-reader,代码行数:8,代码来源:StreamingCell.java


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