Class 'ZipArchive' 未在 PHPExcel 中找到

Class 'ZipArchive' not found in PHPExcel

我在名为 "Collective Access" 的程序中遇到以下错误,但我不确定从这里到哪里去,因为我以前从未遇到过此类问题:

PHP Fatal error:  Uncaught Error: Class 'ZipArchive' not found in /var/www/html/providence/app/lib/core/Parsers/PHPExcel/PHPExcel/Reader/Excel2007.php:94
Stack trace:
#0 /var/www/html/providence/app/lib/core/Parsers/PHPExcel/PHPExcel/IOFactory.php(268): PHPExcel_Reader_Excel2007->canRead('project/mapping...')
#1 /var/www/html/providence/app/lib/core/Parsers/PHPExcel/PHPExcel/IOFactory.php(191): PHPExcel_IOFactory::createReaderForFile('project/mapping...')
#2 /var/www/html/providence/app/models/ca_data_importers.php(768): PHPExcel_IOFactory::load('project/mapping...')
#3 /var/www/html/providence/app/lib/ca/Utils/CLIUtils.php(1147): ca_data_importers::loadImporterFromFile('project/mapping...', Array, Array)
#4 /var/www/html/providence/support/bin/caUtils(166): CLIUtils::load_import_mapping(Object(Zend_Console_Getopt))
#5 {main}
  thrown in /var/www/html/providence/app/lib/core/Parsers/PHPExcel/PHPExcel/Reader/Excel2007.php on line 94

PS - 这是它引用的文件第 94 行附近的代码:

$xl = false;
    // Load file
    $zip = new $zipClass;
    if ($zip->open($pFilename) === true) {
        // check if it is an OOXML archive
        $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
        if ($rels !== false) {
            foreach ($rels->Relationship as $rel) {
                switch ($rel["Type"]) {
                    case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
                        if (basename($rel["Target"]) == 'workbook.xml') {
                            $xl = true;
                        }
                        break;

                }
            }
        }
        $zip->close();
    }

    return $xl;
}

编辑

我正在为 php 使用 7.0.15-0ubuntu0.16.04.4(或者 Ubuntu 服务器 16.04.4 上的版本 7.0)

ZipArchive class is provided by the Zip PHP extension that, according to its documentation 需要在 PHP(Linux 上)或 php.ini(Windows 上)的编译中启用。

很可能您的系统上没有该扩展程序。在新文件中写入 <?php phpinfo();,在浏览器中打开(通过网络服务器)并检查 Zip 扩展是否已编译或启用。

如果您的脚本是命令行工具,那么 运行 使用 PHP CLI 或 运行 在终端中 phpinfo() 文件:

$ php -m

查看加载的扩展(模块)列表或

$ php -i

查看phpinfo()显示的完整信息。