4

I have the following code which I run on localhost and works perfectly:

$objWriter = new PHPExcel_Writer_Excel2007($excel);    
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="'.$excel_file.'"');
$objWriter->save('php://output');

The same code uploaded on another host returns a 404 "File Not Found" error.

Any ideea why?

14
  • 1
    404 not found likely means that the page isn't at the URL where you expect it to be, but it's nothing to do with PHPExcel Commented Apr 14, 2013 at 17:09
  • 2
    The page is exactly at the URL where I expect it to be. Commented Apr 14, 2013 at 17:10
  • Note that you're sending the wrong headers for the filetype: The Excel2007 Writer is used to create an OfficeOpenXML (xlsx) file, which has a mime type of application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; a mime type of application/vnd.ms-excel identifies a BIFF format (xls) file, created by the Excel5 Writer Commented Apr 14, 2013 at 17:11
  • Check your webserver logs, but a 404 return status means page not found Commented Apr 14, 2013 at 17:12
  • 1
    I have no rewrite rules. I also tried with xlsx and that mime type, but still the same error. Its not actually a 404, it says: "File not found. Firefox can't find the file at [...]. Check the file name for capitalization or other typing errors. Check to see if the file was moved, renamed or deleted." Commented Apr 14, 2013 at 17:20

2 Answers 2

4

I was facing the same issue. It was working in local but not on live server. Just confirm below installation on live server and it will work.

  • PHP extension php_zip enabled
  • PHP extension php_xml enabled
  • PHP extension php_gd2 enabled
Sign up to request clarification or add additional context in comments.

Comments

0

Today I combacted against this problem.

I saw that Firefox told me "File not found", but HTTP code in the header was a 500 (server error).

I had a mistake writing a formula; once I corrected the formula the error is disappeared.

I've error reporting at paranoid level, display errors active, and I watched at apache error*.log files, but I've received no comunications from the library/ PHP / Apache about the error.

I foudn the error just commenting out one group row at time in the code until I catched the error.

I've no explanation why this error throws non logs.

1 Comment

It could be that whatever is throwing the error is suppressed with @. php.net/manual/en/language.operators.errorcontrol.php

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.