PHP ExcelをHTML出力 excel2html

GitHubのリンク

< インストール >

composer でインストールします。

[????@????]# composer require tomk79/php-excel2html
Cannot load Zend OPcache - it was already loaded
No composer.json in current directory, do you want to use the one at /home/ApacheDoc/invfiles? [Y,n]? n
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? y
Info from https://repo.packagist.org: #StandWithUkraine
./composer.json has been created
Running composer update tomk79/php-excel2html
Loading composer repositories with package information
Updating dependencies
Lock file operations: 14 installs, 0 updates, 0 removals
  - Locking ezyang/htmlpurifier (v4.16.0)
  - Locking maennchen/zipstream-php (2.1.0)
  - Locking markbaker/complex (3.0.2)
  - Locking markbaker/matrix (3.0.1)
  - Locking michelf/php-markdown (1.9.1)
  - Locking myclabs/php-enum (1.8.4)
  - Locking phpoffice/phpspreadsheet (1.25.2)
  - Locking psr/http-client (1.0.2)
  - Locking psr/http-factory (1.0.2)
  - Locking psr/http-message (1.1)
  - Locking psr/simple-cache (1.0.1)
  - Locking symfony/polyfill-mbstring (v1.27.0)
  - Locking tomk79/filesystem (1.2.3)
  - Locking tomk79/php-excel2html (0.1.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 14 installs, 0 updates, 0 removals
  - Installing ezyang/htmlpurifier (v4.16.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.27.0): Extracting archive
  - Installing psr/http-message (1.1): Extracting archive
  - Installing myclabs/php-enum (1.8.4): Extracting archive
  - Installing maennchen/zipstream-php (2.1.0): Extracting archive
  - Installing markbaker/complex (3.0.2): Extracting archive
  - Installing markbaker/matrix (3.0.1): Extracting archive
  - Installing psr/http-client (1.0.2): Extracting archive
  - Installing psr/http-factory (1.0.2): Extracting archive
  - Installing psr/simple-cache (1.0.1): Extracting archive
  - Installing tomk79/filesystem (1.2.3): Extracting archive
  - Installing phpoffice/phpspreadsheet (1.25.2): Extracting archive
  - Installing michelf/php-markdown (1.9.1): Extracting archive
  - Installing tomk79/php-excel2html (0.1.2): Extracting archive
5 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
3 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found

< コード例 >

<?php

require_once( '../vendor/autoload.php' );

ini_set("memory_limit", "-1");
ini_set('max_execution_time', 180);

// == リクエストパラメータ == //
$filename = $_POST["filename"] ? $_POST["filename"] : $_GET["filename"];

if (!$filename) {
  $filename = "/path/filename.xlsx";
}

$src = (new \tomk79\excel2html\main($filename))->get_html(
        array(
            'renderer' => 'strict',
            'cell_renderer' => 'html',
            'render_cell_width' => true,
            'render_cell_background' => true,
            'render_cell_borders' => true,
            'render_cell_align' => true,
            'render_cell_vertical_align' => true,
        ));

print $src;

< 画面例 >

コメントを残す