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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:58:54+00:00 2026-06-11T18:58:54+00:00

I want to export data from mysql tables to excel sheet. I am using

  • 0

I want to export data from mysql tables to excel sheet. I am using excel 2007. Once this code was working properly but today I am getting problem. Please guide me where I am doing wrong. I have huge data about 60,000 rows.

<?php
/* 
Export MySQL to Excel using PHP & HTML tables
Author: Vlatko Zdrale, http://blog.zemoon.com

Look but don't touch :)
*/
    include "mysql_connection.php";
    //$dbTable = 'info';            // table name
    $con=open_db_connection();


    $sql = "select info_id, name, category_list.category, company_name, company_address, company_phone, date from info, city_list, category_list where city=cid and info.category=id";
    $result = @mysql_query($sql)    or die("Couldn't execute query:<br>".mysql_error().'<br>'.mysql_errno());

    header('Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');   //define header info for browser
    header('Content-Disposition:attachment; filename=information-'.date('Ymd').'.xlsx');
    header('Pragma: no-cache');
    header('Expires: 0');

    echo '<table><tr>';
    for ($i = 0; $i < mysql_num_fields($result); $i++)   // show column names as names of MySQL fields
        echo '<th>'.mysql_field_name($result, $i).'</th>';
    print('</tr>');

    while($row = mysql_fetch_row($result))
    {
        //set_time_limit(60); // you can enable this if you have lot of data
        $output = '<tr >';
        for($j=0; $j<mysql_num_fields($result); $j++)
        {
            if(!isset($row[$j]))
                $output .= '<td>&nbsp;</td>';
            else
                $output .= "<td>$row[$j]</td>";
        }
        print(trim($output))."</tr>\t\n";
    }
    echo('</table>');
?>

Its very important please guide me. Thanks in advance.

  • 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-11T18:58:55+00:00Added an answer on June 11, 2026 at 6:58 pm

    You will get that message because the file isn’t an OfficeOpenXML xlsx file, but a file containing HTML markup with a .xlsx extension. You’re telling Excel that the file is one format by the extension when it’s really another, and it let’s you know that the content doesn’t match the extension. As long as it can read the HTML markup cleanly, it should still load successfully, but will always issue this message.

    The more recent versions of Excel are more fussy about this than earlier versions.

    If you want to get rid of the message, then either you rename your .xlsx as a .html file so that the extension matches the content (you’ll need to import into Excel then, or moodify file associations so that html files are opened using Excel); or give it a tab-separated value file with a csv extension (that can be opened by double click), though you can’t add any formatting using this option; or give it a real OfficeOpenXML .xlsx file

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

Sidebar

Related Questions

I want to export data and structure from MySQL database using PHP. I know
I am using a PHP script to export data from MySQL into Excel. The
I'm trying to export the data from MS Excel sheet to a datatable using
I want to export my data from grid view to the excel. Unfortunately i
I want to export some data from my jruby on rails webapp to excel,
I am using PHPExcel to export data from my PHP page to Excel. I
I have an export SQL file containing tables and data from MySQL and I
I want to export numerical data from C# to Excel where the floating point
I am trying to export data from database to excel 2007 file. I just
I want to export data from a table to a specifically formatted XML file.

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.