无效的单元格坐标phpExcel

时间:2012-04-13 10:48:50

标签: cell phpexcel coordinate

我已经测试了如果使用vlookup在自助表中搜索“= vlookup(h2,A2:B2000,2,False)”并从其他表单返回值“= SupplierList!A2”和“= vlookup(SupplierList! H3,A2:B2000,2,False)“也没关系。

那么为什么只有“= vlookup(h3,SupplierList!A2:B2000,2,False)”会出错?

---------------------------错误消息------------------ -------------

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

---------------------------错误消息------------------ -------------

Cell是这样的公式 **=IF(ISERROR(VLOOKUP(H2349,'Supplier List'!A:B,2,FALSE)),"-",VLOOKUP(H2349,'Supplier List'!A:B,2,FALSE))**

2 个答案:

答案 0 :(得分:0)

评论太久......

调试计算错误时,我使用以下内容:

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');

这提供了计算引擎正在执行的所有操作的相当详细的日志,从而可以识别问题的原因。

如果您只想在保存文件时禁用单元格值计算,则可以在实例化yor writer之后但在发出save命令之前发出以下命令:

$objWriter->setPreCalculateFormulas(FALSE);

答案 1 :(得分:-1)

para resolver esse problema“无效的单元格坐标”$ this-&gt; caracteres = array(             '','A','B','C','D','E','F','G','H','I','J','K','L' ,'M',             'N','O','P','Q','R','S','T','U','V','X','Y','W','Z ”,             'AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM ”,             'AN','AO','AP','AQ','AR','AS','AT','AU','AV','AX','AY','AW','AZ “);

adicione mais caracteres,             'AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM ”,             'AN','AO','AP','AQ','AR','AS','AT','AU','AV','AX','AY','AW','AZ “); ....

英 解决这个问题“无效的单元格坐标”$ this-&gt; characters = array( '','A','B','C','D','E','F','G','H','I','J','K','L' ,'M', 'N','O','P','Q','R','S','T','U','V','X','Y','W','Z “ 'AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM “ 'AN','AO','AP','AQ','AR','AS','AT','AU','AV','AX','AY','AW','AZ “);

添加更多字符, 'AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM “ 'AN','AO','AP','AQ','AR','AS','AT','AU','AV','AX','AY','AW','AZ “); ....