You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Mark Beardsley <ma...@tiscali.co.uk> on 2012/02/28 09:24:55 UTC

Re: How do i get formula in excel workbook using apache poi 3.7?

Not certain what you are asking here but I am going to assume you want to get
at the formula a cell contains so that you can see whether it contains - for
example - the IF function.

The quick and dirty method - without recourse to using the formula parser is
quite simple;

1. Get the cells type - cell.getCellType()
2. Compare that to the constant Cell.CELL_TYPE_FORMULA.
3. If they are equal, you have a formula cell and can get at the formula
itself by calling the getCellFormula() method on the cell.

That will return a String that encapsulates the formula entered into the
cell and you can then use Java's String handling functionalist to see what
formula you have.

Alternatively, use the method Yegor outlined and simply look at the tokens,
stepping through them to see what function/formula you have.

There is no pre-defined method in POI that simply allows you to conduct a
search operation on the contents of cells in a sheet; you would have to
write that for yourself.

--
View this message in context: http://apache-poi.1045710.n5.nabble.com/How-do-i-get-formula-in-excel-workbook-using-apache-poi-3-7-tp5520843p5521186.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How do i get formula in excel workbook using apache poi 3.7?

Posted by Ade <ad...@yahoo.com>.
Many thanks Mark, will try this

--
View this message in context: http://apache-poi.1045710.n5.nabble.com/How-do-i-get-formula-in-excel-workbook-using-apache-poi-3-7-tp5520843p5523095.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org