You can use PHP to generate Excel files. Teaman translation
----------------------------
Excel functions
----------------------------
Save the following code as excel.php and include it in the page
and then call
1. Call Xlsbof ()
2. Write some content to Xlswritenunber () or Xlswritelabel ().
3. Then invoke call Xlseof ()
You can also use the Fwrite function to write directly to the server, rather than using echo only to display on the browser.
<?php
-----The begin of Function library-----
Excel begin with 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, $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:
<?php
Header ("Expires:mon, June June 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.