gpt4 book ai didi

PHPExcel xlsx 文件阅读器

转载 作者:行者123 更新时间:2023-12-04 20:56:35 24 4
gpt4 key购买 nike

我有一个问题,其中一个读取的数字是正确的,因为在 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 documentation 中所述

关于PHPExcel xlsx 文件阅读器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46446676/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com