1

There is a report, which a server automatically creates in my Intranet.

I can access it and download it via an url like this:

http://www1.intranet.com/reportingtool.asp?settings=var&export = ok

I want to use it with PHPExcel.

$objPHPExcel = PHPExcel_IOFactory::load("file.xls");

When I swop file.xls with the url it doesn't work.

Which alternative way can I use to avoid the step by manually downloading the excel-file and writing the file-name in the code?

1 Answer 1

1

You can't...

To parse the xls file, PHPExcel needs to be able to move the file pointer backward and forward through the file as it reads data from the OLE streams; which isn't an option with a file retrieved via url, only with a file that is physically available on the server filesystem.

Workaround (downloading to a temporary file):

$url = 'http://www1.intranet.com/reportingtool.asp?settings=var&export=ok';
$tmpfname = tempnam(sys_get_temp_dir());
file_put_contents(
    $tmpfname,
    file_get_contents($url)
);
$objPHPExcel = PHPExcel_IOFactory::load($tmpfname);

though you'll probably need to manually delete $tmpfname afterwards

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

1 Comment

Okay that is also a solution. Thanks so much! I think I have to build something like a Cronjob with downloads the report and renames it ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.