i would like to know how can i use PhpSpreadsheet symfony 3 , should i use this bundle : roromix/SpreadsheetBundle, can i have a little exemple how to use it to read rows from exemple_file.xlst
thank you
i would like to know how can i use PhpSpreadsheet symfony 3 , should i use this bundle : roromix/SpreadsheetBundle, can i have a little exemple how to use it to read rows from exemple_file.xlst
thank you
I would advice to use the PHPSpreadsheet package directly.
$spreadsheet = PhpSpreadsheet\IOFactory::load('exemple_file.xlst' );
$worksheet = $spreadsheet->getActiveSheet(); // get active worksheet
$rows = []; //empty array of rows
foreach ($worksheet->getRowIterator() AS $row) {
$cells = $row->getCellIterator();
$cells->setIterateOnlyExistingCells(FALSE); // iterates through all cells, including empty ones
$cellData = [];//
foreach ($cells as $cell) {
$cellData[] = $cell->getValue();
}
$rows[] = $cells;
}
This will create 2 - dimensional array "rows" containing all the worksheet data which you can then use to import to DB. Or you can import it directly row by row in the for loop.