Guest User

Untitled

a guest
Nov 24th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. $test_location = "/test.xls"
  2.  
  3. /**
  4. * @var \PHPExcel $excel
  5. * @var \PHPExcel_Reader_CSV $reader
  6. */
  7. /** @noinspection PhpUndefinedMethodInspection */
  8. $reader = \PHPExcel_IOFactory::createReader('CSV')
  9. ->setInputEncoding("euc-kr")
  10. ->setDelimiter("\t")
  11. ->setEnclosure('"')
  12. ->setSheetIndex(0);
  13. $excel = $reader->load($test_location);
  14.  
  15. foreach ($excel->getWorksheetIterator() as $worksheet) {
  16. foreach ($worksheet->getRowIterator() as $row) {
  17. echo "<br/>" . ' Row number - ' , $row->getRowIndex(); echo "<br/><br/>";
  18. $cellIterator = $row->getCellIterator();
  19. $cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
  20. foreach ($cellIterator as $cell) {
  21.  
  22. if (!is_null($cell)) {
  23. echo $cell->getCoordinate() , ' - ' , $cell->getValue(), "<br />\n\r";
  24. }
  25. }
  26. }
  27. }
Add Comment
Please, Sign In to add comment