Answer the question
In order to leave comments, you need to log in
How to wrap a phpexcel class?
Hello!
Recently I read this article on Habré: habrahabr.ru/post/136540 .
I can't use this function on my local:
public function getCellValue($cellOrCol, $row = null, $format = 'd.m.Y')
{
//column set by index
if(is_numeric($cellOrCol)) {
$cell = $this->activeSheet->getCellByColumnAndRow($cellOrCol, $row);
} else {
$lastChar = substr($cellOrCol, -1, 1);
if(!is_numeric($lastChar)) { //column contains only letter, e.g. "A"
$cellOrCol .= $row;
}
$cell = $this->activeSheet->getCell($cellOrCol);
}
//try to find current coordinate in all merged cells ranges
//if find -> get value from head cell
foreach($this->mergedCellsRange as $currMergedRange){
if($cell->isInRange($currMergedRange)) {
$currMergedCellsArray = PHPExcel_Cell::splitRange($currMergedRange);
$cell = $this->activeSheet->getCell($currMergedCellsArray[0][0]);
break;
}
}
//simple value
$val = $cell->getValue();
//date
if(PHPExcel_Shared_Date::isDateTime($cell)) {
$val = date($format, PHPExcel_Shared_Date::ExcelToPHP($val));
}
//for incorrect formulas take old value
if((substr($val,0,1) === '=' ) && (strlen($val) > 1)){
$val = $cell->getOldCalculatedValue();
}
return $val;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question