Php generates excel dongdongdong_php skills

Source: Internet
Author: User
Tags domain name registration
Php can be used to generate excel files through php .?? Teaman translation ---------------------------- ExcelFunctions -------------------------- save the following code as excel. php, include it in the page, and then call 1. CallxlsBOF ()? Php skills for generating excel dongdongdong_php

You can use PHP to generate an EXCEL file .?? 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 (9999 );?? // Write a number B1
XlsEOF (); // close the stream
?>

Article: Western Digital-professional domain name registration and virtual hosting services
Http://www.west263.com?
The above information is an integral part of the text. if you want to reprint this article, please keep the above information. thank you!Php skills for generating excel dongdongdong_php

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.