![](/img/trans.png)
[英]PHPExcel xlsx file into array ....Reader_Exception: Could not open
[英]PHPExcel xlsx file reader
我有一个问题,其中一个读取的数字是正确的,因为在 excel 工作表中它只是一个数字,但第二个返回一个公式。 我已经尝试了在论坛的其他主题上建议的几种方法,但它们都不能正常工作。 我还能做些什么来解决这个问题? 我只需要从我的 .xlsx excel 文件中读取几个单元格。
代码:
include "PHPExcel-1.8\Classes\PHPExcel\IOFactory.php";
$inputFileName = 'C:\Users\tfd054it0154\Desktop\dane na spotkanie.xlsx';
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
// Read Excel workbook
try {
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
} catch(Exception $e) {
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}
$value1 = $objPHPExcel->getActiveSheet()->getCell('B8')->getValue();
echo $value1;
$value2 = $objPHPExcel->getActiveSheet()->getCell('C8')->getValue();
echo $value2;
如果单元格包含公式,则getValue()
返回公式本身, getCalculatedValue()
计算并返回该公式的结果。
如PHPExcel 文档中所述
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.