PHPExcel在Windows下出錯 修復方案

2022-03-26 05:27:18 字數 1537 閱讀 8814

安裝好phpexcel,可以使用composer安裝;

第乙個錯誤是phpzip庫沒有找到,ziparchive and lib-zip.dll

phpexcel內建的zip庫pclzip

phpexcel 有乙個 pclzip 類,作為 lib_zip 缺失的情況下的備胎,具體可以看( from stackoverflow )

需要在載入iofactory方法前 新增一句phpexcel_settings::setzipclass(phpexcel_settings::pclzip);來切換到內建的zip庫。

路徑有問題classes/shared/ziparchive.php

但是內建的 classes/shared/ziparchive.php 類有個不相容windows路徑的錯誤需要更正一下,在方法public function getfromname($filename)(141行)。

找到的錯誤是傳進來的$filename包含的路徑是這樣的のxl/_rels/workbook.xml.rels(即使在windows下也是斜線模式,*nix)但是實際在$list陣列中的卻是windows的反斜線風格xl\_rels\workbook.xml.rels,斜線和反斜線不匹配,so 問題來了。

需要在匹配的if判斷中新增反斜線的匹配!!!!!!!!!!!!!

# before

if (strtolower($list[$i]["filename"]) == strtolower($filename) || strtolower($list[$i]["stored_filename"]) == strtolower($filename)) ", strtolower($filename)) == strtolower($list[$i]["filename"]) || strtolower($list[$i]["stored_filename"]) == strtolower($filename) || str_replace("/", "\u", strtolower($filename)) == strtolower($list[$i]["stored_filename"])) is backslash

還會有乙個問題就是 "**variable contents is not defined", so 再小改一下

# before

if ( is_array($extracted) && $extracted > 0 )

return $contents;

#after

$contents = "";

if ( is_array($extracted) && $extracted > 0 )

return false;

現在可以在php7(windows)中使用了

libevent 在window環境編譯

系統 win7 編譯器 vc2010 2,解壓到目錄libevent 2.0.14 stable 3,修改 d libevent 2.0.10 stable event iocp.c d libevent 2.0.10 stable evthread win32.c d libevent 2.0.1...

在Window中使用 AWK

一直以來都認為awk只能在linux unix中才能使用,今天偶然查到有window版本的awk。安裝設定path,包含安裝目錄 c program files x86 gnuwin32 bin 說明 源資料是模擬售票機的歷史記錄,字段含義 銷售日期,出發站名稱,到達站名稱,購買票的數量,總金額 d...

docker在centos和windows的安裝

yum remove docker docker client docker client latest docker common docker latest docker latest logrotate docker logrotate docker engine yum install y ...