Class 'ZipArchive' not found error while u

2020-06-23 09:17发布

When I use PHPExcel on a new server, I faced the error "Class 'ZipArchive' not found" and it seems to be blocked by my hosting service provider.

Can't I use PHPExcel on the server without Zip support? PHP 5.2.8 is installed on this server but I can't use a basic PHP source code for PHPExcel.

Any help will be appreciated, thanks.

1条回答
别忘想泡老子
2楼-- · 2020-06-23 09:49

Certain spreadsheet file formats, such as OfficeOpenXML used as the default format by Excel 2007 and above, require ZipArchive. In most recent versions of PHP, ZipArchive is always available, but prior to PHP 5.3 it needed to be manually installed on some systems as a PHP extension.

If you don't have ZipArchive installed/enabled for your PHP, and can't enable it yourself, then you can use

PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);

PCLZip is included in the PHPExcel distribution as an alternative to PHP's built-in ZipArchive class, though it is quite a bit slower. Enabling PCLZip allows you to work with zip-based spreadsheet formats even without ZipArchive.

However, when we first bundled PCLZip (originally in PHPExcel 1.7.6), it was only an option when writing zip-based formats, not when reading them. We changed that in PHPExcel 1.8.0, so enabling PCLZip now allows you to read zip-based formats as well as writing them.

The PHPEXcel Reader documentation details the different spreadsheet formats, and explains which ones are zip-based. PHPEXcel Reader documentation

查看更多
登录 后发表回答