将Excel文件从变量加载到PHP_Excel中 [英] Load excel file into PHP_Excel from variable

查看:137
本文介绍了将Excel文件从变量加载到PHP_Excel中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有这个

file_put_contents($tmpfile, $attachments[0]['body']);
$objPHPExcel = PHPExcel_IOFactory::load($tmpfile);

我正在读取的文件是从电子邮件中提取的,因此将其写入临时文件 我想将其从字符串直接读入phpexcel中(如果有意义)

The file I am reading is extracted from an email, so rather then writing it to a tempfile I would like to read it directly into phpexcel from a string (if that makes sense)

$objPHPExcel = PHPExcel_IOFactory::load($attachments[0]['body']);

我看过php excel手册,但是看不到如何做,有什么主意吗?

I have looked at the php excel manual but can't see how to do it, any ideas?

推荐答案

PHPExcel没有提供直接方法来从字符串而不是文件中加载.但是,作为为$ tmpfile实际创建物理文件系统文件的替代方法,您可以使用 php://memory php://temp

PHPExcel provides no direct method for loading from a string rather than from a file. As an alternative to actually creating a physical filesystem file for $tmpfile though, you might be able to use php://memory or php://temp

这篇关于将Excel文件从变量加载到PHP_Excel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆