gpt4 book ai didi

PHPExcel工作表索引越界异常

转载 作者:行者123 更新时间:2023-12-04 14:12:09 26 4
gpt4 key购买 nike

我正在使用 PHPExcel 阅读 xlsx 工作簿,以下是我目前使用的代码,只是为了设置事件工作表

date_default_timezone_set('Europe/London');
set_include_path(get_include_path() . PATH_SEPARATOR . './Classes/');

include 'PHPExcel/IOFactory.php';

$reader = PHPExcel_IOFactory::createReader('Excel2007');
$reader->setReadDataOnly(true);
$xlWB = $reader->load('/' . $target_file);
$xlWB->setActiveSheetIndex(0); //EXCEPTION OCCURS HERE

但我有一个异常(exception):

Fatal error: Uncaught exception 'PHPExcel_Exception' with message 'You tried to set a sheet active by the out of bounds index: 0. The actual number of sheets is 0.' in /[my root]/Classes/PHPExcel.php:695 Stack trace: #0 /[my-root]/conversion-demo.php(211): PHPExcel->setActiveSheetIndex(0) #1 {main} thrown in /[my root]/Classes/PHPExcel.php on line 695



该文件是一个 .xlsx 文件,它确实存在(路径正确)并且文件中有 3 张纸。

我在这里做错了什么吗?

最佳答案

检查您从何处获取文件的权限 - 我刚刚在文件上传时遇到了这个问题,并在 Windows\Temp 中更改了权限修复了它。

关于PHPExcel工作表索引越界异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36136816/

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