Read XLXS file in PHP and display header.

DDD
Release: 2024-10-02 14:08:01
Original
602 people have browsed it

Read XLXS file in PHP and display header.

Read XLXS file using PHP

  • Use lib from GitHub call XLSXReader XLSXReader will helps to achieve this as it provide all the require functions. so, it begin with call it and use it further.

After install Composer and XLSXREADER call below file at top.

require('./XLSXReader.php');

Copy after login
  • Use any ExcelSheet for example..
    Add any Excel file in root of the project directory. So, we can use it latter.

  • Create index.php file and add below code.

<?php
require('./XLSXReader.php');
$targetPath = './hello world.xlsx';
$xlsx = new XLSXReader($targetPath);
$sheetNames = $xlsx->getSheetNames();
$imports=array();
$html="";
foreach($sheetNames as $sheetName) {

    $sheet = $xlsx->getSheet($sheetName);
    echo "<h3>".$sheet->sheetName."</h3>";

    $html.="<table border='1'>";
    foreach($sheet->getData() as $row) {
        $html.="<tr>";
        foreach($row as $key){
            $html.="<td>".$key."</td>"; 
        }
        $html.="<tr>";  
    }
    $html.="</table>";
}
echo $html;
Copy after login

Run it on your local or server. For more about demo and output visit at programmerdesk

The above is the detailed content of Read XLXS file in PHP and display header.. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!