Skip to content

Instantly share code, notes, and snippets.

@aazbeltran
Last active August 29, 2015 14:24
Show Gist options
  • Save aazbeltran/633086ba444ca63a99ed to your computer and use it in GitHub Desktop.
Save aazbeltran/633086ba444ca63a99ed to your computer and use it in GitHub Desktop.
Clase Excel para el manejo de PHPExcel
<?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