Created
October 4, 2013 11:26
-
-
Save jbrooksuk/6824507 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class XLS { | |
public function __construct($strFileName) { | |
header("Pragma: public"); | |
header("Expires: 0"); | |
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
header("Content-Type: application/force-download"); | |
header("Content-Type: application/octet-stream"); | |
header("Content-Type: application/download"); | |
header("Content-Disposition: attachment;filename=$strFileName.xls"); | |
header("Content-Transfer-Encoding: binary"); | |
$this->xlsBOF(); | |
} | |
public function __destruct() { | |
$this->xlsEOF(); | |
} | |
public function xlsWriteNumber($Row, $Col, $Value) { | |
echo pack("sssss", 0x203, 14, $Row, $Col, 0x0); | |
echo pack("d", $Value); | |
} | |
public function xlsWriteLabel($Row, $Col, $Value) { | |
$L = strlen($Value); | |
echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L); | |
echo $Value; | |
} | |
public function xlsWriteRow($Row, $Values) { | |
$Col = 0; | |
foreach($Values as $Value) { | |
$this->xlsWriteLabel($Row, $Col, utf8_decode($Value)); | |
$Col++; | |
} | |
} | |
// PRIVATE INTERNAL FUNCTIONS | |
private function xlsBOF() { | |
echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); | |
} | |
private function xlsEOF() { | |
echo pack("ss", 0x0A, 0x00); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment