Q: php returning excel file from server, that i dont want to i have file called Admission.xls in my server
i want to write $_POST data in that file & save it in the server only, i dont to return to the user, but it returning to user
Here is my code
<?php 

// ----- begin of function library ----- 
// Excel begin of file header 
function xlsBOF() { 
    echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);  
    return; 
    } 
// Excel end of file footer 
function xlsEOF() { 
    echo pack("ss", 0x0A, 0x00); 
    return; 
} 
// Function to write a Number (double) into Row, Col 
function xlsWriteNumber($Row, $Col, $Value) { 
    echo pack("sssss", 0x203, 14, $Row, $Col, 0x0); 
    echo pack("d", $Value); 
    return; 
} 
// Function to write a label (text) into Row, Col 
function xlsWriteLabel($Row, $Col, $Value ) { 
    $L = strlen($Value); 
    echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
    echo $Value; 
return; 
} 
// ----- end of function library -----

// ------ MS EXCEL START ------

header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT"); 
header ("Cache-Control: no-cache, must-revalidate");     
header ("Pragma: no-cache");     
header ('Content-type: application/x-msexcel'); 
header ("Content-Disposition: attachment; filename=Admission.xls" );  
header ("Content-Description: PHP/INTERBASE Generated Data" );

// -----LOOP $_POST VALUES -----
$row = 2;
$col = 1;
xlsBOF();
foreach($_POST as $value ) {
    xlsWriteLabel($row, $col, $value );
    $col++;
}
xlsEOF();

// ------ MS EXCEL END -----
?>  

if possible please tell me how to open, write and save excel file that is in server
THANK you 

A: You can do this by capturing the output buffer and write it to a file.
Read up on this here: http://www.php.net/manual/en/book.outcontrol.php

This how you do it in your script.
Remove these:
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT"); 
header ("Cache-Control: no-cache, must-revalidate");     
header ("Pragma: no-cache");     
header ('Content-type: application/x-msexcel'); 
header ("Content-Disposition: attachment; filename=Admission.xls" );  
header ("Content-Description: PHP/INTERBASE Generated Data" );

And change your foreach loop code like this:
// -----LOOP $_POST VALUES -----
ob_start();
$row = 2;
$col = 1;
xlsBOF();
foreach($_POST as $value ) {
    xlsWriteLabel($row, $col, $value );
    $col++;
}
xlsEOF();
$xlsData = ob_get_contents();
ob_end_clean();

// -----WRITE EXCEL DATA TO FILE--
$h = @fopen('Admission.xls', 'w');
if ($h) {
    fwrite($h, $xlsData);
    fclose($h);
}

// -----
exit('Post data written to Admission.xls on server.');


A: I think you can use PHPExcel, you will be having lots of methods to achieve this task.
Have look here
