Reputation: 2876
I am trying to make a PHP file to run online (e.g. http://www.writephponline.com/ and alternatively I can use PUTTY). This script will get an excel file from a link. Then it will save it to a folder (given link). It seems that there is an error.
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();
The error is :
01) Class 'PHPExcel_Reader_Excel2007' not found
UPD:
I even tried that :
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");
and I got :
02) PHPExcel_IOFactory
I have included the source though and I don't know why it is not working. Is there a public link for PHPExcel.php so I can test?
Upvotes: 1
Views: 3499
Reputation: 755
You can't require fully qualified php files from a server, it expects a file.
Right now your require is just getting the output of the files you are including, as it is making a request to that URL.
Upvotes: 0
Reputation: 467
Alternatively you can read your file like this;
$reader = PHPExcel_IOFactory::createReaderForFile($inputFileName);
$reader->setReadDataOnly(true);
$workbook = $reader->load($inputFileName);
Unless you have special reason for choosing to use PHPExcel_Reader_Excel2007
Upvotes: 1