php excel公式字段返回0
我使用的是php excel公式字段返回0,php,odbc,phpexcel,Php,Odbc,Phpexcel,我使用的是PHPExcel\u 1.8.0,只是从一个文件中读取数据并将其保留到另一个字段 工作正常,但公式字段有问题。。对于任何公式字段,其返回0 我的代码可以告诉我如何获取值而不是0吗 $objReader = PHPExcel_IOFactory::createReaderForFile($full_file_withputh); $this->objPHPExcel = $objReader->load($full_file_withputh);
PHPExcel\u 1.8.0
,只是从一个文件中读取数据并将其保留到另一个字段
工作正常,但公式字段有问题。。对于任何公式字段,其返回0
我的代码可以告诉我如何获取值而不是0吗
$objReader = PHPExcel_IOFactory::createReaderForFile($full_file_withputh);
$this->objPHPExcel = $objReader->load($full_file_withputh);
$row_number=$this->opobj->start_row;
if(isset($this->opobj->dataset)) {unset($this->opobj->dataset);}
$this->opobj->dataset[$counter][$col_number]=$this->objPHPExcel->getActiveSheet(0)->getCellByColumnAndRow($col_number,$row_number)->getValue();
我也试过了
$this->opobj->dataset[$counter][$col_number]=$this->objPHPExcel->getActiveSheet(0)->getCellByColumnAndRow($col_number,$row_number)->getCalculatedValue();
但是它不起作用我在一个使用PHPExcel的项目中工作,遇到了许多这样的问题。看完这些文档后,我想如果我使用下面的代码,我会得到预期的值
$field_value = $this->objPHPExcel
->getActiveSheet(0)
->getCellByColumnAndRow($col_number,$row_number)
->getFormattedValue();
if($field_value == null) {
$field_value = $this->objPHPExcel
->getActiveSheet(0)
->getCellByColumnAndRow($col_number,$row_number)
->getOldCalculatedValue();
}
嗨,谢谢大家的支持。。。。 因为我已经尝试了几种方法,但没有得到我想要的结果。。。所以我改变了读取文件的方式。。。我使用php odbc读取文件
$excelFile = realpath($full_file_withputh);
$excelDir = dirname($excelFile);
$connection = odbc_connect("Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=$excelFile;DefaultDir=$excelDir" , '', '');
$result = odbc_exec ($connection, "select * from [sheet$] ");
$row = odbc_fetch_array($result)
默认情况下,它将第一行作为字段名
它成功了您需要给我们提供更多的信息。。。你能举一个失败公式的例子吗?通过PHPExcel引擎…此单元格中的公式是什么?被引用单元格的值是什么?它是简单的文本,但它是从不同的表中获取的调用
getValue()
返回的实际值是什么?这应该是一个包含实际公式的字符串:如果返回的是0
,那么getCalculatedValue()
肯定也会返回0
。。。。如果为该单元格调用getDataType()
,则应返回一个“f”以指示公式,并且单元格中的值(通过getValue()
检索)应具有“=”作为第一个字符第一个字符是“规划阶段”!J3,该字段引用的是=IFERROR(I9,”),现在我试图用getCalculatedValue()获取该单元格,但没有区别谢谢,但getFormattedValue不适用于我/我的版本,所以我使用了value