Video of 35 must-learn secret techniques for excel spreadsheets. PHP generates EXCEL stuff.

WBOY
Release: 2016-07-29 08:34:28
Original
961 people have browsed it

EXCEL files can be generated through PHP. Teaman translation
-------------------------------
Excel Functions
------- ---------------------
Save the following code as excel.php, then include it in the page
Then call
1. Call xlsBOF()
2 . Write some content to xlswritenunber() or xlswritelabel().
3. Then call Call xlsEOF()
You can also use the fwrite function to write directly to the server instead of using echo to only display it on the browser.
// ----- 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 above introduces the video of 35 must-learn secret techniques for excel tables. PHP generates EXCEL stuff, including the content of the video of 35 must-learn secret techniques for excel tables. I hope it will be helpful to friends who are interested in PHP tutorials.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template