Reading Excel xlsx files in PHP without ZipArchive class or PHP extension php_zip enabled

扶醉桌前 提交于 2019-12-23 05:29:17

问题


I am using PHPExcel PHP library for reading xlsx files and every thing is fine. when I am deploying my web application in our server I am facing the below error:

Fatal error: Uncaught exception 'Exception' with message 'ZipArchive library is not enabled'

I know that ZipArchive is a requirement for PHP Excel. and I need to follow the install instructions for it to enable it on my production server.

This error because PHPExcel require the below requirements:

  1. PHP version 5.2.0 or higher
  2. PHP extension php_zip enabled
  3. PHP extension php_xml enabled
  4. PHP extension php_gd2 enabled

Now I cant access our nginx server and cant compile "PHP extension php_zip" then enable it.

my question is:

Is that any Alternatives for PHP_excel dose not require ZipArchive class with PHP extension php_zip enabled ?

I am trying these Alternatives for PHP_excel but all of them based on zip.so compiled and php_zip extension enabled.

Any help will be more than appreciated.


回答1:


Since version 1.8.0, PHPExcel has offered an alternative built-in Zip handler that can be enabled by setting

PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);

before loading any files that are zip-based archives such as xlsx or ods

This is slower and uses more memory than PHP's own ZipArchive extension, but provides an alternative if ZipArchive isn't enabled



来源:https://stackoverflow.com/questions/23626594/reading-excel-xlsx-files-in-php-without-ziparchive-class-or-php-extension-php-zi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!