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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:15:31+00:00 2026-06-16T05:15:31+00:00

I want to generate XLS files with a PHP script from a MySQL database.

  • 0

I want to generate XLS files with a PHP script from a MySQL database. The big problem here is that when I open the new exported .xls file, I see the values OK (i.e. it is correctly formatted) but the colour of the field changed to white. However, I need the colour unchanged, as is by default in Excel.

Here is the PHP script that I use to extract data from my database.

 <?php
            include 'connect.php';
            $result = mysql_query('SELECT * FROM projects2');

            ?>

        <center><h1>Lista valorilor din tabela</h1>
        <h2><a href="lec_datepm.php?exporta_lista_clienti=1" title="Exporta lista clienti in Excell" target="_blank">Exporta lista Clienti</a></h2></center>

        <?php
            include_once 'tabel_clientipm.php';
        ?>

The PHP file used to generate the XLS file is:

<?php
    include 'connect.php';
    $result = mysql_query('SELECT * FROM projects2');

    if (isset($_GET['exporta_lista_clienti'])) {
    $filename = 'raportnou.xls';

    header("Content-type: application/ms-excel");
    header("Content-Disposition: attachment; filename=$filename");

    include_once 'tabel_clientipm.php';

    exit();
    }
?>

I added the tabel_clientipm.php:

<center>
<table border="1">
    <tr>
        <th>surname</th>
        <th>name</th>
        <th>age</th>

    </tr>
    <?php
        while ($client = mysql_fetch_assoc($result)) {
    ?>
    <tr>
        <td><?php echo $client['surname'];?></td>
        <td><?php echo $client['name'];?></td>
        <td><?php echo $client['age'];?></td>

    </tr>
    <?php
        }
    ?>
</table>
</center>
  • 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-16T05:15:32+00:00Added an answer on June 16, 2026 at 5:15 am

    If you want to create real .xls file NOT csv or html hidden in .xls extension use PHPExcel or

    It supports the following formats.

    • BIFF 8 (.xls) Excel 95 and above
    • Office Open XML (.xlsx) Excel 2007 and above

    If PHPExcel is slow for you check these alternatives (provided by an author of PHPExcel. All of them are faster than PHPExcel

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

Sidebar

Related Questions

I want generate static pages from database. What is a better suggestion that a
I want to generate an MS Excel file from PHP. I know one can
I want generate PDF File with an image. The image name from database and
I want to generate a list of files where the name consists of ${filename}.${date}
I want to generate an HTML table from a couple specified parameters. Specifically, the
I want to generate a bar graph from from a csv file my data
I want to generate a LaTeX document from Objective-C and compile it with pdfLatex
I want generate a list of numbers from 0000 to 9999. I would then
I want to generate all combination of length r from a set [0...(n-1)] So
I want to generate 32x32 sized thumbnails from uploaded images (actually avatars). To prevent

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.