-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't open XLSX sheet, out of bounds -1 #4391
Comments
Neither do I. Can you upload your spreadsheet? |
sure thing. I think I deleted anything "incriminating" |
Thank you for providing your spreadsheet. I am unable to duplicate your result with that spreadsheet and your code. Is it possible that the error is happening later than you think? What release of PhpSpreadsheet (from the above I think it's 4.1.0) and Php are you using? What environment? My code (only minor modifications from yours): <?php
require __DIR__ . '/PhpSpreadsheet' . '/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
class issue4391 {
public static function issue(): void
{
$inputFileType = 'Xlsx';
$inputFileName = 'issue.4391.xlsx';
$reader = IOFactory::createReader($inputFileType);
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($inputFileName);
$activeWorksheet = $spreadsheet->getActiveSheet();
var_dump($activeWorksheet->getCell('A7')->getValue());
}
}
issue4391::issue(); My result:
|
I copied your code, changed the path to vendor/autoload.php $ php testsheet.php do my dependencies look ok? |
Your dependencies match mine. I am at a loss to think of why your result should differ from mine. |
are there any environmental variables that could effect this? php? |
I just tried this on an Ubuntu 24.04 machine (vs Fedora 41) and no errors. |
I'm glad you found this, but it seems awfully surprising. Do you have a way of testing if you can use ZipArchive on Fedora 41 to read other zip files? (An Xlsx spreadsheet is a zip archive composed mostly of xml files.) |
PHP Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Exception: Your requested sheet index: -1 is out of bounds. The actual number of sheets is 0. in /home/gauze/phpspread/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php:626
$ file po1326.xlsx
po1326.xlsx: Microsoft Excel 2007+
^ opens ok in windows and libreoffice
$ composer show|grep spreadsheet
phpoffice/phpspreadsheet 4.1.0 PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
[code snippet]
$inputFileType = 'Xlsx';
$inputFileName = DIR . '/po1326.xlsx';
$reader = IOFactory::createReader($inputFileType);
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($inputFileName);
$activeWorksheet = $spreadsheet->getActiveSheet();
[snip]
throws error here.
I do not know what is wrong here.
thanks
brian
The text was updated successfully, but these errors were encountered: