spout
spout copied to clipboard
Previous issue #861 prematurely closed
I had
require_once 'Autoloader/autoload.php';
previously, and it made no difference. I have added it back in, and again, no difference. Are there edits needed?
$srcBaseDirectory =\dirname(\dirname(__FILE__));
hardly looks legitimate?
Still get "This page isn't working"
Just tested, and this works:
<?php
require_once '[PATH_TO_SPOUT]/src/Spout/Autoloader/autoload.php';
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
$filePath = '[PATH_TO_FILE]';
$reader = ReaderEntityFactory::createReaderFromFile($filePath);
$reader->open($filePath);
foreach ($reader->getSheetIterator() as $sheet) {
foreach ($sheet->getRowIterator() as $row) {
// do stuff with the row
$cells = $row->getCells();
}
}
$reader->close();
great. no more errors. now, when I try to retrieve data from the file, nothing happens:
<?php
require_once 'Autoloader/autoload.php';
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
$filePath = 'csv/20220127160717 prop.xlsx';
$reader = ReaderEntityFactory::createReaderFromFile($filePath);
$reader->open($filePath);
foreach ($reader->getSheetIterator() as $sheet) {
foreach ($sheet->getRowIterator() as $row) {
// do stuff with the row
$cells = $row->getCells();
$line_num = $cells[1];
echo $line_num;
}
}
$reader->close();
?>
You're reading an XLSX file that's inside a csv
folder. Maybe this is not really a XLSX file?
Anyway, the code you're using is correct and should work. The problem must come from the file you're using. Try to check the logs, there should be an error somewhere.
I created a file in a new workbook with 10 rows and one column as a test. It doesn't read it.
I'm going to find another solution.
Steve Spence, KK4HFJ
On Mon, Feb 7, 2022 at 12:25 AM Adrien Loison @.***> wrote:
You're reading an XLSX file that's inside a csv folder. Maybe this is not really a XLSX file? Anyway, the code you're using is correct and should work. The problem must come from the file you're using. Try to check the logs, there should be an error somewhere.
— Reply to this email directly, view it on GitHub https://github.com/box/spout/issues/862#issuecomment-1030917661, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQPILKLROBBZ2IIVJZMNZE3UZ3RLFANCNFSM5NAY7XYQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>