Hi again,

I forgot to say that I've also tried with this:

In the main class I make the call:
wb2.addToolPack(new GEFAddIn());

public class GEFAddIn  implements UDFFinder{

     private final Map<String, FreeRefFunction> _functionsByName;

     public GEFAddIn() {
         // dummy function that returns NA
// don't care about the implementation, we are not interested in evaluation
         // and this method will never be called
         FreeRefFunction NA = new FreeRefFunction() {
             public ValueEval evaluate(ValueEval[] arg0,
                     OperationEvaluationContext arg1) {
                 return ErrorEval.NA;
             }
         };
         _functionsByName = new HashMap<String, FreeRefFunction>();
         _functionsByName.put("Calculo_VPS", NA);

     }

     public FreeRefFunction findFunction(String name) {
         return _functionsByName.get(name.toUpperCase());
     }

}

But it works the same as the other.

Thanks in advance


El 20/11/2012 18:25, Ruben Garcia escribió:
Good afternoon,

I'm trying to set a formula set in my ExcelSheet template, which contains a VB function to do some calculations. I followed this example http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/ss/examples/formula/SettingExternalFunction.java but when I create the ExcelSheet, the Cell where I set the formula doesn't show the value, it shows a "name error". Here is my code:

                Workbook wb2 = WorkbookFactory.create(fis);
                String[] functionNames = {"Calculo_VPS"};
FreeRefFunction[] functionImpls = {new FreeRefFunction() {

                        @Override
                        public ValueEval evaluate(ValueEval[] arg0,
                                OperationEvaluationContext arg1) {
// don't care about the returned result. we are not going to evaluate BDP
                               return ErrorEval.NA;

                        }
                     }};

UDFFinder udfToolpack = new DefaultUDFFinder(functionNames,
                     functionImpls);

                     // register the user-defined function in the workbook
                     wb2.addToolPack(udfToolpack);

row2.createCell(19).setCellFormula(formulaC19);
                wb2.setForceFormulaRecalculation(true);

I've also tried with this one:
row2.createCell(19).setCellType(HSSFCell.CELL_TYPE_FORMULA);
row2.getCell(19)..setCellFormula(formulaC19);

Could anyone help me with this?
--


--

Reply via email to