Hi!

We would like to create a UDF, which accesses the cell in which a certain
formula is called and successive cells. (We fill workbooks with data..)

I have tried all day to find a way to do this, but it seems impossible
except this ugly approach:
- Pass the SSWorkbook into the UDF on creation (Because EvaluationWorkbook
does not support getSheetAt())
- Access private field _sheetIndex on OperationEvaluationContext
- Get sheet from SSWorkbook and thus gain access to cell...

public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec)
{
     int sheetIndex = 0;
     try
     {
         Field f =
OperationEvaluationContext.class.getDeclaredField("_sheetIndex");
         f.setAccessible(true);
         sheetIndex = (Integer)f.get(ec);
     }
     catch(Exception e1)
     {
         e1.printStackTrace();
     }
     Sheet sheet = wb.getSheetAt(sheetIndex);
   ...
}

This works, but it is obviously not something we would like to do. Does
anybody know of a better solution to do this?

Any help or hint would be greatly appreciated,
Best Regards

Tibu




--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Access-Cell-In-UDF-tp5716676.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to