Invalid cell coordinate phpExcel

cellcoordinatephpexcel

I have tested that if using vlookup to search in the self sheet "=vlookup(h2, A2:B2000, 2, False)" and returning value from other sheet "=SupplierList!A2" and "=vlookup(SupplierList!H3, A2:B2000, 2, False)" are also fine.

so why only "=vlookup(h3, SupplierList!A2:B2000, 2, False)" drives into error?

————————— ERROR MESSAGE ——————————-

Fatal error: Uncaught exception 'Exception' with message 'PO!G2 -> Invalid cell coordinate A' in C:\Program Files\EasyPHP-5.3.6.0\www\ExcelImporter\Classes\PHPExcel\Cell.php:288 Stack trace: #0 C:\Program Files\EasyPHP-5.3.6.0\www\ExcelImporter\Classes\PHPExcel\Cell.php(204): PHPExcel_Cell->getCalculatedValue() #1 C:\Program Files\EasyPHP-5.3.6.0\www\ExcelImporter\Documentation\Examples\index.php(36): PHPExcel_Cell->getFormattedValue() #2 {main} thrown in C:\Program Files\EasyPHP-5.3.6.0\www\ExcelImporter\Classes\PHPExcel\Cell.php on line 288

————————— ERROR MESSAGE ——————————-

The Cell is with formula like this
**=IF(ISERROR(VLOOKUP(H2349,'Supplier List'!A:B,2,FALSE)),"-",VLOOKUP(H2349,'Supplier List'!A:B,2,FALSE))**

Best Answer

Too long to be a comment...

When debugging calculation errors, I use the following:

function testFormula($sheet,$cell) {
    $formulaValue = $sheet->getCell($cell)->getValue();
    echo '<b>'.$cell.' Value is </b>'.$formulaValue."<br />\n";
    $expectedValue = $sheet->getCell($cell)->getOldCalculatedValue();
    echo '<b>'.$cell.' Expected Value is </b>'.((!is_null($expectedValue)) ? $expectedValue : 'UNKNOWN')."<br />\n";


    $calculate = false;
    try {
        $tokens = PHPExcel_Calculation::getInstance()->parseFormula($formulaValue,$sheet->getCell($cell));
        echo '<b>Parser Stack :-</b><pre>';
        print_r($tokens);
        echo '</pre>';
        $calculate = true;
    } catch (Exception $e) {
        echo "PARSER ERROR: ".$e->getMessage()."<br />\n";

        echo '<b>Parser Stack :-</b><pre>';
        print_r($tokens);
        echo '</pre>';
    }

    if ($calculate) {
        try {
            $cellValue = $sheet->getCell($cell)->getCalculatedValue();
            echo '<b>'.$cell.' Calculated Value is </b>'.$cellValue."<br />\n";

            echo '<h3>Evaluation Log:</h3><pre>';
            print_r(PHPExcel_Calculation::getInstance()->debugLog);
            echo '</pre>';
        } catch (Exception $e) {
            echo "CALCULATION ENGINE ERROR: ".$e->getMessage()."<br />\n";

            echo '<h3>Evaluation Log:</h3><pre>';
            print_r(PHPExcel_Calculation::getInstance()->debugLog);
            echo '</pre>';
        }
    }
}


$sheet = $objPHPExcel->getActiveSheet();
PHPExcel_Calculation::getInstance()->writeDebugLog = true;


testFormula($sheet,'A4');

This provides a fairly detailed log of everything that the calculation engine is doing, allowing the cause of the problem to be identified.

If you simply want to disable cell value calculation when saving a file, then you can issue the following command after instantiating yor writer, but before issuing the save command:

$objWriter->setPreCalculateFormulas(FALSE);
Related Topic