1

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?

5
  • Are you using any autoloader script for your own code? If so, then it could be clashing with PHPExcel's autoloader Commented Sep 16, 2016 at 11:51
  • @MarkBaker That's all I have in my script. Nothing else. I am trying to run the file online phpfiddle.org and writephponline.com Commented Sep 16, 2016 at 12:05
  • Then tough! There is no way you can include the entirety of PHPExcel via a remote url at runtime, and I don't know any PHP libraries/frameworks that permit that Commented Sep 16, 2016 at 12:05
  • Like most/all PHP libraries, PHPExcel expects you to have downloaded the library and to have it locally on the same server as the rest of your code Commented Sep 16, 2016 at 12:06
  • Yo might conceivably be able to do this if you included a phar file via a link, I guess that's possible, though I've never tried it Commented Sep 16, 2016 at 12:08

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

The problem hints in the PHPExcel. it says "Class 'PHPExcel_IOFactory' not found".
This could be as a result of namespace. Add use PHPExcel_IOFactory
I added 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');
I mean use the namespace PHPExcel_IOFactory explicitly after requiring the appropriate files. After the require_once statements just before your class/method declaration add the statement use PHPExcel_IOFactory
0

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.

8 Comments

But still I am getting an error : require_once(apolosiskos.co.uk/Classes/IOFactory.php): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error -- at line 22
I noticed you are using full qualified urls on your require, updating my asnwer
Yes. 100%. I do not know why the links do not open.
So, isn't there a public link that will load this libraries?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.