Export data to xlsx format (need it quickly please )

dear everyone
i am exporting my data to *.xls format and it working very well and here it is my code


<?
session_start();
	if($_SESSION['archived_b']==1)
	{
		include('DBconnect_archived.php');
	//	echo 'here';
	}
	else
	{
		include('DBconnect.php');
	}	
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;
}
?>
<?
 // Query Database

	$table_name='';
	$select_query1 =  $_SESSION['query'];
	//print "select_query1: " . $select_query1 . "<br>";
	$res_query1 = mysql_query($select_query1)
	or die ("table error: " . mysql_error());
$res_rows = mysql_num_rows($res_query1);
//echo $res_rows;
//$tr_res_query1 = mysql_fetch_array($res_query1);

//or


	 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-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    header("Content-Disposition: attachment;filename=Action_Report_".date('dmys').".xls");
    header("Content-Transfer-Encoding: binary ");
	
	
//  	dato 	 	 	 	 	
    // XLS Data Cell

                 xlsBOF();
                xlsWriteLabel(0,0,"No.");
                xlsWriteLabel(0,1,"Action Date");
                xlsWriteLabel(0,2,"Action");
                xlsWriteLabel(0,3,"Travel Agency");				
                xlsWriteLabel(0,4,"Office ID");
                xlsWriteLabel(0,5,"Terminal ID");
                xlsWriteLabel(0,6,"SignInitials");		
                xlsWriteLabel(0,7,"Comments");		
                xlsWriteLabel(0,8,"Insert Date");														

                $xlsRow = 1;	
					while ($tr_res_query1 = mysql_fetch_array($res_query1))
					{
											
				
														 	if($_SESSION['archived_b']==1)
															{
																$inserted_dato='N/A';
															}
															else
															{	$inserted_dato=date("M j, Y h:i A", strtotime($tr_res_query1['datetimeo']));
															}
															
															
                    ++$i;
                          xlsWriteNumber($xlsRow,0,"$i");
                          xlsWriteLabel($xlsRow,1, date('D dS \\ M Y', strtotime($tr_res_query1['ActionDate'])));
                          xlsWriteLabel($xlsRow,2, $tr_res_query1['Action']);
                          xlsWriteLabel($xlsRow,3,select_travel($tr_res_query1['OID']));						
                          xlsWriteLabel($xlsRow,4, $tr_res_query1['OID']);
                          xlsWriteLabel($xlsRow,5, $tr_res_query1['ATID']);
                          xlsWriteLabel($xlsRow,6, $tr_res_query1['SignInitials']);		
                          xlsWriteLabel($xlsRow,7, $tr_res_query1['Comments']);	
                          xlsWriteLabel($xlsRow,8,$inserted_dato);						  						  				  						
			
				    $xlsRow++;
					
					}
				
                     xlsEOF();
                 exit();

?>

[COLOR=“#FF0000”]my problem is that i need to export these data to *.xlsx format, i tried to make the name to

Action_Report_".date('dmys').".xlsx"

[/COLOR] but it did not work

does anyone has a module or source code to make this task

i need it quickly please

Hi John,

You might want to take a look at the PHPExcel library, it can convert between quite a few different spreadsheet formats, including .xls and .xlsx