%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php class Excel { public $filename; public $headerArray; public $bodyArray; public $rowNo = 0; function __construct($filename='export.xls') { $this->filename = $filename; } public function addHeader($header) { if(is_array($header)) { $this->headerArray[] = $header; } else { $this->headerArray[][0] = $header; } } public function addRow($row) { if(is_array($row)) { if(is_array($row[0])) { foreach($row as $key=>$array) { $this->bodyArray[] = $array; } } else { $this->bodyArray[] = $row; } } else { $this->bodyArray[][0] = $row; } } public function returnSheet() { return $this->buildXLS(); } public function sendFile() { $xls = $this->buildXLS(); 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=".$this->filename); header("Content-Transfer-Encoding: binary "); echo $xls; exit; } private function buildXLS() { $xls = pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); if(is_array($this->headerArray)) { $xls .= $this->build($this->headerArray); } if(is_array($this->bodyArray)) { $xls .= $this->build($this->bodyArray); } $xls .= pack("ss", 0x0A, 0x00); return $xls; } private function build($array) { foreach($array as $key=>$row) { $colNo = 0; foreach($row as $key2=>$field) { if(is_numeric($field)) { $build .= $this->numFormat($this->rowNo, $colNo, $field); } else { $build .= $this->textFormat($this->rowNo, $colNo, $field); } $colNo++; } $this->rowNo++; } return $build; } private function textFormat($row, $col, $data) { $data = utf8_decode($data); $length = strlen($data); $field = pack("ssssss", 0x204, 8 + $length, $row, $col, 0x0, $length); $field .= $data; return $field; } private function numFormat($row, $col, $data) { $field = pack("sssss", 0x203, 14, $row, $col, 0x0); $field .= pack("d", $data); return $field; } } ?>