Php generates EXCEL files. you can use php to generate EXCEL files. teaman translation ---------------------------- ExcelFunctions -------------------------- save the following code as excel. php, which can be included in the page to generate an EXCEL file through PHP. teaman translation
----------------------------
Excel Functions
----------------------------
Save the following code as excel. php and include it in the page.
Then call
1. Call xlsBOF ()
2. write some content to xlswritenunber () or xlswritelabel.
3. Call xlsEOF ()
You can also use the fwrite function to directly write data to the server, instead of simply displaying data in the browser with echo.
// ----- 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 -----
?>
//
// To display the contents directly in a MIME compatible browser
// Add the following lines on TOP of your PHP file:
Header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT ");
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=EmplList.xls ");
Header ("Content-Description: PHP/INTERBASE Generated Data ");
//
// The next lines demonstrate the generation of the Excel stream
//
XlsBOF (); // begin Excel stream
XlsWriteLabel (0, 0, "This is a label"); // write a label in A1, use for dates too
XlsWriteNumber (0, 1, 9999); // write a number B1
XlsEOF (); // close the stream
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.