在没有ZipArchive类或PHP扩展名php_zip的情况下,在PHP中读取Excel xlsx文件 [英] Reading Excel xlsx files in PHP without ZipArchive class or PHP extension php_zip enabled

查看:561
本文介绍了在没有ZipArchive类或PHP扩展名php_zip的情况下,在PHP中读取Excel xlsx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PHPExcel PHP库读取xlsx文件,一切都很好。
当我在我的服务器中部署我的Web应用程序时,我面临下面的错误:

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'

我知道 ZipArchive 是一个要求为PHP Excel。我需要安装说明,以启用它我的生产服务器。

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.

此错误是因为 PHPExcel 需要以下要求:

This error because PHPExcel require the below requirements:


  1. PHP版本5.2.0或更高版本

  2. PHP扩展名php_zip enabled

  3. PHP扩展名php_xml启用

  4. PHP扩展名php_gd2启用

  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

现在我无法访问我们的 nginx 服务器,无法编译PHP扩展名php_zip,然后启用它。

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

我的问题是:

PHP_excel的任何替代方案不需要 ZipArchive类与PHP扩展名php_zip启用

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

我正在尝试这些 Alterna PHP_excel的生活,但都是基于zip.so编译和
php_zip扩展名启用。

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.8.0版本起,PHPExcel提供了一个可选的内置Zip处理程序,可通过设置

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);

在加载任何基于zip的档案(如xlsx或ods)的文件

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

这是比PHP自己的ZipArchive扩展更慢的内存,但是如果ZipArchive没有启用,则提供一个替代方案

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

这篇关于在没有ZipArchive类或PHP扩展名php_zip的情况下,在PHP中读取Excel xlsx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆