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

  • SEARCH
  • Home
  • 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 7629355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:48:55+00:00 2026-05-31T05:48:55+00:00

In using PHP to output an Excel file, it is working fine, however, each

  • 0

In using PHP to output an Excel file, it is working fine, however, each Excel file has 3 blank rows at the top. The headers are such:

<?php
header ("Expires: Mon, 28 Oct 2008 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-type: application/vnd.ms-excel");
header ("Content-Disposition: attachment; filename=\"GridExport.xls" );
header ("Content-Description: Generated Report" );
echo $content_for_layout;
?>

In looking at the 3 blank rows in a text editor such as notepad, I actually see one blank row, following by a row with a single space, following by another blank row, so that is basically equivalent to:

\n.\n\n

where the period = single space.

Finally, when I do open the file in Excel > 2003, I get this error message about the file not being in the right format, yet clicking yes opens it fine (minus the 3 blank row problem). Is it possible to send the right headers to not get this message? See a screenshot at:

https://twiki.auscope.org/wiki/pub/Grid/WfsReaderWs/OpenFileWarning.png

  • 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-05-31T05:48:56+00:00Added an answer on May 31, 2026 at 5:48 am

    If you output CVS with an XLS extension Excel 2007 and above will give you a warning that it isn’t an excel file, but open it anyway. Earlier versions will not give that warning.
    Outputing it correctly as a CSV file will not cause that error, or prevent other CVS handling applications from handling it.

    As to what the lines are – impossible to tell without knowing what is in $content_for_layout

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a PHP file to output an XML Document. I'm using a CSS
I'm using fputcsv in PHP to output a comma-delimited file of a database query.
I'm using PHP to output data from an XML file, specifically the date, which
I'm using PHP to output data from a sports XML file (in this example
im able to output an excel file by php and it opens correctly in
Im using PHP to output the category information from an RSS feed: foreach(item_category()) as
I am using php to output some rich text. How can I strip out
I'm using PHP 5.2. I'd like to find a way to output a unique
Is it possible to output specific JSON data (exported from Firefox bookmarks) using PHP.
I use object buffering to buffer the output of my php pages using ob_start('ob_gzhandler');

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.