1

我已经测试过,如果使用 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

- - - - - - - - - - - - - - 错误信息 - - - - - - - - - - - ----------

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

4

2 回答 2

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);
于 2012-04-17T06:32:54.493 回答
-1

para resolver esse problema "无效的单元格坐标" $this->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-> 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'); ……

于 2013-09-03T16:43:09.047 回答