我有一个读取数字是正确的问题,因为在Excel工作表中它只是一个数字,但第二个返回一个公式。我已经尝试了几个关于论坛其他主题的方法,但都没有正确的工作。我还能做些什么来解决这个问题?我只需要从我的.xlsx excel文件中读取几个单元格。PHPExcel xlsx文件读取器
代码:
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;
可能的复制描述(https://stackoverflow.com/questions/563670/reading-an-excel-file-in-php) –