PHP远程读取excel文件,怎么读取

PHP远程读取excel文件,怎么读取,第1张

PHPExcel 通过 PHPExcel_Shared_OLERead 类的 read 方法读取文件

但 read 方法里使用了 is_readable 函数来确认文件是否存在,而 is_readable 不能作用于 url

所以不可直接远程读取

但若绕过 is_readable 函数的话,就是可以的

public function read($sFileName)

{

// Check if file exists and is readable

if(!is_readable($sFileName)) {

throw new Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable.")

}

// Get the file data

$this->data = file_get_contents($sFileName)

写段伪代码给你:

//先获取远程网页的源代码

$html = file_get_contents(http://mp3.baidu.com/歌曲播放页.html)

//用正则表达式分析源代码中的资源链接

$link = preg_match_all(正则)...

//读取资源文件

$bin = file_get_contents(http://mp3.baidu.com/时间都去哪了.mp3)

//保存资源文件到本地

$fp = fopen(时间都去哪了.mp3, wb)

$fp.writh($bin)

$fp.close()

先说好,不要让我写完整的源代码,因为这里还涉及一些细节,比如说,你才提供的 xls ,就是需要登录的,那么你还要实现模拟登录。

有些网站的资源链接有各种限制,需要你慢慢去深入。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/8106508.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存