[英]Open excel file using PHPExcel and save it to a folder
我正在尝试制作一个在线运行的 PHP 文件(例如http://www.writephponline.com/ ,或者我可以使用 PUTTY)。 此脚本将从链接中获取一个 excel 文件。 然后它将其保存到一个文件夹(给定链接)。 似乎有错误。
include 'my_link/Classes/PHPExcel.php';
$inputFileName = 'FILE_NAME';
$reader = new PHPExcel_Reader_Excel2007;
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$reader = PHPExcel_IOFactory::createReader($inputFileType);
$workbook = $reader->load($file);
$objWriter = PHPExcel_IOFactory::createWriter($workbook, 'Excel2007');
$objWriter->save('FOLDER_NAME');
exit();
错误是:
01) 找不到类“PHPExcel_Reader_Excel2007”
更新:
我什至尝试过:
require_once('apolosiskos.co.uk/Classes/PHPExcel.php');
require_once('apolosiskos.co.uk/Classes/IOFactory.php');
require_once('apolosiskos.co.uk/Classes/Excel2007.php');
$fileType=PHPExcel_IOFactory::identify("FILE.xlsx");
$objReader = PHPExcel_IOFactory::createReader("Excel2007");
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("FILE.xlsx");
$objWriter->save("http://apolosiskos.co.uk/output.xlsx");
我得到了:
02) PHPExcel_IOFactory
我已经包含了源代码,但我不知道为什么它不起作用。 是否有 PHPExcel.php 的公共链接以便我进行测试?
或者,您可以像这样阅读您的文件;
$reader = PHPExcel_IOFactory::createReaderForFile($inputFileName);
$reader->setReadDataOnly(true);
$workbook = $reader->load($inputFileName);
除非您有特殊原因选择使用PHPExcel_Reader_Excel2007
您不能要求来自服务器的完全限定的 php 文件,它需要一个文件。
现在您的 require 只是获取您包含的文件的输出,因为它正在向该 URL 发出请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.