2012-04-13 67 views
1

我测试过,如果使用vlookup在自我表单中搜索“= vlookup(h2,A2:B2000,2,False)”,并从其他表格“= SupplierList!A2”和“= vlookup(SupplierList!H3,A2:B2000,2,False)“也很好。无效的单元格坐标phpExcel

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

--------------------------- 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

---------------------------出错信息-------------------------------

所述细胞与式这样 **=IF(ISERROR(VLOOKUP(H2349,'Supplier List'!A:B,2,FALSE)),"-",VLOOKUP(H2349,'Supplier List'!A:B,2,FALSE))**

+0

那么消息表明,在计算树中的某处有一个对单元“PO!G2”的引用,其中包含需要计算的公式......所以,单元格的值是什么“PO!G2 “? – 2012-04-16 06:43:06

回答

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

这提供了计算引擎正在尽一切的相当详细的日志,使问题的原因进行鉴定。

$objWriter->setPreCalculateFormulas(FALSE); 
-1

对解析器ESSE problema“无效:

如果你只是想保存文件时禁用单元格值计算,那么你就可以实例侑后作家,但发出save命令之前发出以下命令单元坐标“$ this-> caracteres = array( '','A','B','C','D','E','F','G','H','I' ,'J','K','L','M', 'N','O','P','Q','R','S','T','U', 'A','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'); 'A'','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' '''','T','U','V','X','Y','W','Z''AA','AB','AC','AD ','AE','AF','AG','AH','AI','AJ','AK','AL','AM''AN','AO','AP',' 'A','AR','AS','AT','AU','AV','AX','AY','AW','AZ');

添加更多字符 “AA”“AB”“AC”“AD”“AE”“AF”“AG”“AH”“AI”“AJ” 'A','A','A','AM','A','AM','A'','A''','A'','A'','A'','A''' ,'AY','AW','AZ'); ...