spout icon indicating copy to clipboard operation
spout copied to clipboard

Previous issue #861 prematurely closed

Open KK4HFJ opened this issue 3 years ago • 4 comments

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"

KK4HFJ avatar Jan 28 '22 13:01 KK4HFJ

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();

adrilo avatar Jan 30 '22 14:01 adrilo

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();

?>

KK4HFJ avatar Jan 31 '22 06:01 KK4HFJ

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.

adrilo avatar Feb 06 '22 21:02 adrilo

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: @.***>

KK4HFJ avatar Feb 07 '22 05:02 KK4HFJ