Home > Backend Development > PHP Tutorial > PHP远程读取excel文件,如何读取?

PHP远程读取excel文件,如何读取?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 13:00:28
Original
1451 people have browsed it

PHP远程读取excel文件,怎么读取??
PHPExcel能远程读取excel文件吗?即读取其他服务器上的文件!

或者有没有其他好的方法能实现?

求方法...

------解决方案--------------------
先用file_get_contents或者curl把文件取回来用phpexcel打开即可
------解决方案--------------------
先把远程的弄到本地里。
最简单代码是:

<br />
file_put_contents('abc.xls',file_get_contents('http://www.xx.com/abc.xls'));<br />
Copy after login

------解决方案--------------------
PHPExcel 通过 PHPExcel_Shared_OLERead 类的 read 方法读取文件
但 read 方法里使用了 is_readable 函数来确认文件是否存在,而 is_readable 不能作用于 url
所以不可直接远程读取
但若绕过 is_readable 函数的话,就是可以的
        public function read($sFileName)<br />
        {<br />
                // Check if file exists and is readable<br />
                if(!is_readable($sFileName)) {<br />
                        throw new Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable.");<br />
                }<br />
<br />
                // Get the file data<br />
                $this->data = file_get_contents($sFileName);<br />
Copy after login

------解决方案--------------------
直接注释代码就好了嘛
或者试用tempnam生成临时文件,记得要删

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template