Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8954367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:18:14+00:00 2026-06-15T14:18:14+00:00

With one of my projects I have users ‘export’ information into Excel files using

  • 0

With one of my projects I have users ‘export’ information into Excel files using PHPExcel. When it works, it works perfectly. Other times, only some people can actually open the files.

Since I need to store the exports that are created, they are saved on the server and then the created file is downloaded using readfile(). When it doesn’t work, (which is most of the time now) people get the ‘wrong file format’ error. The really odd thing is that since the file is saved, they can try downloading that same file again. Then it works.

Here is my final save and download code:

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="'.$Temp_Export_File_Name.'"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//$objWriter->save('php://output');
$objWriter->save('../project_files_images/created_exports/'.$Temp_Export_File_Name);
readfile('../project_files_images/created_exports/'.$Temp_Export_File_Name);
exit;

Is there something wrong with this code that I am missing? The problem tends to show itself most for users of the latest versions of Office (Mac or Windows)

Thanks for the input.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:18:14+00:00Added an answer on June 15, 2026 at 2:18 pm

    Mark’s tip was correct. For anyone else that might run into this, here is what was happening.

    PHPExcel, for some reason, requires a ‘Creator’ and ‘Last Modified By’ field and I am not using them. I simply commented out the 2 lines of code within the PHPExcel code which referred to these 2 items.

    It still doesn’t explain why it effected the forced file and not the saved file, but the theory I am running with is this.

    1. The saved file was created by all the header information set and saved.
    2. The forced file somehow included the printed errors on the head of the file.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three models, one for Projects, other for Users and other to the
So I have a Users table, Projects table and User_Roles table. I have one
I have two projects.One project is build in MVC asp.net and the other project
I have a solution with 3 projects.One of UI (contains web pages) and one
I have the digdog MapKitDragAndDrop in one my projects to achieve drag and drop
I have a Visual Studio C++ solution with 3 projects: one contains all classes
I have upgraded one of my projects in c# from visual studio 2005 to
In one of my projects, I have a very active classic ASP site with
In one of my projects, I have an application that manages several clients (or
I have 2 projects. One project is a core and contains the GUI which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.