Last active
August 29, 2015 14:24
-
-
Save aazbeltran/633086ba444ca63a99ed to your computer and use it in GitHub Desktop.
Clase Excel para el manejo de PHPExcel
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 Excel { | |
private $excel; | |
public function __construct() { | |
require_once APPPATH.'third_party/phpexcel/PHPExcel.php'; | |
$this->excel = new PHPExcel(); | |
} | |
public function load($path) { | |
$objReader = PHPExcel_IOFactory::createReader('Excel5'); | |
$this->excel = $objReader->load($path); | |
} | |
public function save($path) { | |
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5'); | |
$objWriter->save($path); | |
} | |
public function stream($filename) { | |
header('Content-type: application/ms-excel'); | |
header("Content-Disposition: attachment; filename=\"".$filename."\""); | |
header("Cache-control: private"); | |
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5'); | |
$objWriter->save('php://output'); | |
} | |
public function __call($name, $arguments) { | |
if(method_exists($this->excel, $name)) { | |
return call_user_func_array(array($this->excel, $name), $arguments); | |
} | |
return null; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment