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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:51:17+00:00 2026-06-04T00:51:17+00:00

Hi I am exporting my mysql data in excel format currently I have 14k+

  • 0

Hi I am exporting my mysql data in excel format currently I have 14k+ records but the problem is it stuck @188kb but when I tried trimming down the result to 100 records it doesn’t interrupt the download.

Here’s my code:

function xlsBOF() { 
    echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);  
    return; 
} 

function xlsEOF() { 
    echo pack("ss", 0x0A, 0x00); 
    return; 
} 

function xlsWriteNumber($Row, $Col, $Value) { 
    echo pack("sssss", 0x203, 14, $Row, $Col, 0x0); 
    echo pack("d", $Value); 
    return; 
} 

function xlsWriteLabel($Row, $Col, $Value ) { 
    $L = strlen($Value); 
    echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L); 
    echo $Value; 
return; 
}

  mysql_connect($dbhost,$dbuser,$dbpass); 
  //mysql_select_db($dbname) or die("Unable to select database"); 
  $result = mysql_db_query($dbname, "select id, or_number, name, client_code, address, vehicle_info, vehicle_color, plate_num, sticker_type, application_date, amount_paid, traffic_violations, delivery_date, edited_by, phase, version FROM owner order by application_date desc");




// Send Header
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=epal.xls"); // à¹à¸¥à¹‰à¸§à¸™à¸µà¹ˆà¸à¹‡à¸Šà¸·à¹ˆà¸­à¹„ฟล์
header("Content-Transfer-Encoding: binary ");

            xlsBOF(); 
            xlsWriteLabel(0,0,"Current SLVA Owner List:");
            xlsWriteLabel(2,0,"#");
            xlsWriteLabel(2,1,"OR #");
            xlsWriteLabel(2,2,"Name");
            xlsWriteLabel(2,3,"Client Code");
            xlsWriteLabel(2,4,"Address");
            xlsWriteLabel(2,5,"Vehicle Info");
            xlsWriteLabel(2,6,"Vehicle Color");
            xlsWriteLabel(2,7,"Plate #");
            xlsWriteLabel(2,8,"Sticker Type");
            xlsWriteLabel(2,9,"Application Date");
            xlsWriteLabel(2,10,"Amount Paid");
            xlsWriteLabel(2,11,"Traffic Violations");
            xlsWriteLabel(2,12,"Delivery Date");
            xlsWriteLabel(2,13,"Edited By");
            xlsWriteLabel(2,14,"Phase");
            xlsWriteLabel(2,15,"Version");


            $xlsRow = 3;
            while(list($id, $or_number, $name, $client_code, $address, $vehicle_info, $vehicle_color, $plate_num, $sticker_type, $application_date, $amount_paid, $traffic_violations, $delivery_date, $edited_by, $phase, $version) = mysql_fetch_row($result)) {
                      xlsWriteLabel($xlsRow,0, $id);
                      xlsWriteLabel($xlsRow,1,$or_number);
                      xlsWriteLabel($xlsRow,2,$name);
                      xlsWriteLabel($xlsRow,3,$client_code);
                      xlsWriteLabel($xlsRow,4,$address);
                      xlsWriteLabel($xlsRow,5,$vehicle_info);
                      xlsWriteLabel($xlsRow,6,$vehicle_color);
                      xlsWriteLabel($xlsRow,7,$plate_num);
                      xlsWriteLabel($xlsRow,8,$sticker_type);
                      xlsWriteLabel($xlsRow,9,$application_date);
                      xlsWriteLabel($xlsRow,10,$amount_paid);
                      xlsWriteLabel($xlsRow,11,$traffic_violations);    
                      xlsWriteLabel($xlsRow,12,$delivery_date);   
                      xlsWriteLabel($xlsRow,13,$edited_by); 
                      xlsWriteLabel($xlsRow,14,$phase);      
                      xlsWriteLabel($xlsRow,15,$version);  

                  $xlsRow++;
                } 
                 xlsEOF();
             exit();

I gone to several sites/threads but still haven’t found the solution. :'(

  • 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-04T00:51:18+00:00Added an answer on June 4, 2026 at 12:51 am

    This is only a wild guess but you may need to calculate the document size ahead of time and set a “Content-length” header

    header("Content-length: " . strlen($document));
    

    You will have to store your output in a string so you can calculate the length (output buffering might help capture your usage of xlsWriteLabel)

    ob_start();
    xlsBOF();
    xlsWriteLabel();
    // etc etc
    xlsEOF();
    $document = ob_get_contents();
    ob_end_clean();
    header("Content-length: " . strlen($document));
    echo $document;
    exit();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem with exporting MySQL data to CSV file, it print
I've got a little problem with exporting MySQL data to html. The problem is
Exporting select query data from mysql to csv & opening with excel, the leading
Exporting some data from mysql to a csv file using FasterCSV. I'd like the
I have a script for exporting results of a mysql query as a csv
I'm exporting data programatically from Excel to SQL Server 2005 using SqlBulkCopy. It works
I'm using PHPExcel for transferring data between MySQL DB and Excel 2007 worksheets. It
I have some data in one of my mysql table stored as utf8. The
I am exporting a csv file in to mysql db using load data infile
Is it possible to Delimit data in a mysql database row? I have data

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.