Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I installed Excelbundle with PhpExcel library. I want to read excel files I found this function.

How can I use it? Any suggestion?

public function xlsAction()
{
    $filenames = "your-file-name";
    $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($filenames);

    foreach ($phpExcelObject ->getWorksheetIterator() as $worksheet) {
        echo 'Worksheet - ' , $worksheet->getTitle();
        foreach ($worksheet->getRowIterator() as $row) {
            echo '    Row number - ' , $row->getRowIndex();
            $cellIterator = $row->getCellIterator();
            $cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
            foreach ($cellIterator as $cell) {
                if (!is_null($cell)) {
                    echo '        Cell - ' , $cell->getCoordinate() , ' - ' , $cell->getCalculatedValue();
                    }
                }
        }
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
470 views
Welcome To Ask or Share your Answers For Others

1 Answer

My suggestion is "Read the documentation" and start hacking at it. Working with excel is, in my experience, quite complex and time consuming so don't expect other people to solve your problem online.

It seems like you're talking about this bundle: https://github.com/liuggio/ExcelBundle

It has great documentation, even full examples (see "Fake Controller").


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...