You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Huang Xin <so...@gmail.com> on 2013/04/09 12:16:19 UTC
How to get the workbook ref in Apache POI formula (e.g. formula [CELL])?
I want to implement a Excel formula that is CELL function use the Apache POI.
It will return the Current Excel workbook filename when the cell eval expression is =CELL("filename").
I could find the cell's sheet from AreaEval type in other eval expression. Except the CELL expression that only one argument.
public class CELL implements Function1Arg, Function2Arg {
@Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0) {
return evaluate(srcRowIndex, srcColumnIndex, arg0);
}
@Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {
return null;
}
@Override
public ValueEval evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex) {
switch (args.length) {
case 1:
return evaluate(srcRowIndex, srcColumnIndex, args[0]);
case 2:
return evaluate(srcRowIndex, srcColumnIndex, args[0], args[1]);
}
return ErrorEval.VALUE_INVALID;
}
}
Is there somewhere may let me get the Eval expression's workbook reference?
Re: How to get the workbook ref in Apache POI formula (e.g. formula
[CELL])?
Posted by Nick Burch <ap...@gagravarr.org>.
On Tue, 9 Apr 2013, Huang Xin wrote:
> I want to implement a Excel formula that is CELL function use the Apache
> POI.
>
> It will return the Current Excel workbook filename when the cell eval
> expression is =CELL("filename").
How will you get the filename for the workbook though? In most cases, POI
doesn't know what the filename is. In quite a few cases, there is no
filename!
(POI will open from a file or an inputstream, and most kinds of
inputstream are not file backed, so there's no filename to go with them)
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org