Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Excel Reader to read xlsx file

Tags:

php

excel

I found code on how to Read Excel File Data in PHP using PHPExcelReader. It says here that it supports both for xls and xlsx file. However when viewing for xlsx file it says that the file is not readable. It only work when viewing xls file. Is there anything I can add at my code to make it readable for xlsx file too? I've also tried searching for answers in the web but it is still readable. Please help me thank you.

<?php
$filename = "uploads/$filename";
$excel_file = $filename;
$sheet_data = '';         
$table_output = array();  

$max_rows = 0;        
$max_cols = 0;        
$force_nobr = 0;      

require_once 'excel_reader.php';       
$excel = new PhpExcelReader();
$excel->setOutputEncoding('UTF-8');    
$excel->read($excel_file);       
$nr_sheets = count($excel->sheets);       


function make_alpha_from_numbers($number) {
  $numeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  if($number<strlen($numeric)) return $numeric[$number];
  else {
    $dev_by = floor($number/strlen($numeric));
    return make_alpha_from_numbers($dev_by-1) .    
    make_alpha_from_numbers($number-($dev_by*strlen($numeric)));
  }
}
like image 394
amln_ndh Avatar asked Oct 18 '22 15:10

amln_ndh


1 Answers

I think that the reason why you can't read .xslx files is because you don't have the PHP extension 'php_zip' enabled.

like image 148
Cheketo Avatar answered Oct 21 '22 07:10

Cheketo