I want to read my excel file which is xlsx formate. There are some error coming. What can I do? This is cakephp 4. And there I use SimpleXLSX class. There is my index PHP file. index.php
<h2>Upload form</h2>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="Parse" />
</form>
<?php
//https://github.com/shuchkin/simplexlsx/blob/master/src/SimpleXLSX.php THIS CLASS I USE THERE
ini_set('error_reporting', E_ALL);
ini_set('display_errors', true);
echo '<h1>XLSX to HTML</h1>';
if (isset($_FILES['file'])) {
if ( $xlsx = SimpleXLSX::parse( $_FILES['file']['tmp_name'] ) ) {
echo '<h2>Parsing Result</h2>';
echo '<table border="1" cellpadding="3" style="border-collapse: collapse">';
$dim = $xlsx->dimension();
$cols = $dim[0];
foreach ( $xlsx->rows() as $k => $r ) {
echo '<tr>';
for ( $i = 0; $i < $cols; $i ++ ) {
echo '<td>' . ( isset( $r[ $i ] ) ? $r[ $i ] : ' ' ) . '</td>';
}
echo '</tr>';
}
echo '</table>';
} else {
echo SimpleXLSX::parseError();
}
}
Nothing to write in controller.
excelController.php
<?php
namespace App\Controller;
class excelController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null|void Renders view
*/
public function index()
{
}
}