我有一個讀取數字是正確的問題,因爲在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) –