PHP HTML

HOW TO DISPLAY EXCEL AS HTML IN PHP

DOWNLOAD PHPSPREADSHEET

01

- PHP cannot read Excel files natively.

- Navigate to project folder in terminal and run composer require phpoffice/phpspreadsheet.

EXCEL TO HTML IN PHP (A)

02

USE PHPSPREADSHEET require "vendor/autoload.php"; $reader = new \PhpOffice\ PhpSpreadsheet\Reader\Xlsx();

READ EXCEL SPREADSHEET $ss = $reader->load("demo.xlsx"); $as = $ss->getActiveSheet();

EXCEL TO HTML IN PHP (B)

03

foreach ($as->getRowIterator() as $r) {   READ CELLS   $iterator = $r->getCellIterator();   $iterator->   setIterateOnlyExistingCells(false);   OUTPUT HTML   foreach ($iterator as $c)   { echo "<p>". $c->getValue() ." </p>"; } }