I want to know how to read the visible/cal开发者_C百科culated contents of the cells of an Excel Sheet & not the underlying formula. For example:- if a cell contains sum(a1,a5) which equals say 123, then it shud read 123, not sum(a1,a5). Similarly for time, it shud read the time as it is, n not the referential value in ratio of 24:00:00...
Please help me out!!!
Viral Jain
You can use ...->getCell($columnAsLetters.$row)->getCalculatedValue();
as described in this thread: How to automatically read in calculated values with PHPExcel?
If you are unsure about the content of a cell (value or formula included), I recommend you to primarily do a check if the cell has a formula and then copy - paste accordingly. getOldCalculatedValue() is very helpful in this case. Here is an example of that:
$code = $sheet->getCell('A'.$y)->getValue();
if(strstr($code,'=')==true)
{
$code = $sheet->getCell('A'.$y)->getOldCalculatedValue();
}
$objPHPExcel4->setActiveSheetIndex(0)
->setCellValue('A'.$l, $code);
For large data sets, getCalculatedValue() function is really cumbersome and lots of memory will be required to perform correctly.
精彩评论