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 3672114
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:34:10+00:00 2026-05-19T02:34:10+00:00

I am using a PHP script to export data from MySQL into Excel. The

  • 0

I am using a PHP script to export data from MySQL into Excel.
The first row of the Excel sheet is a column heading. I want them to appear in bold. How do I do this?
I am using the following code:

$con = mysql_connect("localhost","admin","password");
if (!$con)
{
    die('Could not connect to DB: \n' . mysql_error());
}

mysql_select_db("ALNMSI", $con);

$result = mysql_query("SELECT * FROM survey1");

$filename = "alnmsi_" . date('d-m-Y') . ".xls";

header("Content-Disposition: attachment; filename=\"$filename\"");

header("Content-Type: application/vnd.ms-excel"); $flag = false;

$flag = false;

while($row = mysql_fetch_array($result))
{
    if(!$flag)
    {
        data_keys();
        $flag = true;
    }
    array_walk($row, 'cleanData');
    data_array($row);
}
  • 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-19T02:34:10+00:00Added an answer on May 19, 2026 at 2:34 am

    I’m assuming you are doing it wrong. Whatever you output it’s probably not a valid Excel file, since you didn’t mention BIFF (this is the binary format which Excel files would be made of).

    If you output TAB or COMMA separated values, then Excel only accidentially opens it correctly. And there is no way to style headers.

    Also read:

    • PHP to Excel, bold font
    • MySQL to Excel generation using PHP
    • Format text in Excel file via PHP
    • Output Excel file in PHP after echo
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV export script (enrdata_arch.php) which calls information from an existing database
I am developing a script in my localhst using PHP and mysql and I
I'm using SQL Server 2005 and I want to export all records from my
I have a simple php script on a server that's using fsockopen to connect
I am using Delphi 7 and ICS components to communicate with php script and
I'm using jQuery to post a form to a php file, simple script to
Using PHP and MySQL, I have a forum system I'm trying to build. What
Been using PHP/MySQL for a little while now, and I'm wondering if there are
I've been using PHP & MySQL for ages and am about to start using
I am currently using CURL via a php script running as daily cron to

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.