Sep 10, 2010 at 10:40 AM
Edited Sep 10, 2010 at 10:41 AM
I know that we can use getValue(), getCalculatedValue() and getOldCalculatedValue() to get the cell value.
If the cell is text, we can use getValue().
If the cell is formula, we can use getCalculatedValue().
But i have a question. I need to get the actual value.
***How to determine the cell format that is text or formula or "VLOOKUP"?
When should I use getValue()?
When should I use getCalculatedValue()?
When should I use getOldCalculatedValue()?
My English is so poor, sorry and thanks...
Sep 10, 2010 at 1:24 PM
On 10/09/2010 10:40, rayin wrote:
> When i should use getValue()?
> When i should use getCalculatedValue()?
> When i should use getOldCalculatedValue()?
You can determine whether a cell contains a formula or a value by using:
$getCellType = $objPHPExcel->getActiveSheet()->getCell('A1')->getDataType();
Possible values returned by this call are:
getOldCalculatedValue() is useful when you have loaded an existing
workbook that was saved with the calculated values for formulae in
cells. Note that not all spreadsheet scripts or applications store a
calculated result for formulae: Gnumeric (for example) always
recalculates all formulae on load, so it doesn't bother storing the
calculated result when you save the file); likewise (when I last tested
it) Excel workbooks created using Apache POI.
When getOldCalculatedValue() does return a result, then this is static.
It doesn't change even if you change the underlying data used by the
formula (even for volatile Excel functions such as NOW() ).
We did briefly consider changing getValue() so that it always returned
the calculated value if the cell contained a formula, and adding
get/setFormula() methods, but were concerned that this would break
backward compatibility for a lot of scripts that already use PHPExcel.
Mark. Thank you very much.