<?
/*
Autor: Lic. Carlos Alberto Vaca Coronado
Version: 3.2.0
*/

session_name('portal_absa');
session_start();
if(!isset($_SESSION['usuario_p_prov_absa']) || trim($_SESSION['usuario_p_prov_absa']) == "" || trim(strtoupper($_SESSION["URL_PORTAL"]."admin.php")) != trim(strtoupper($_SERVER['HTTP_REFERER']))){
	?><script>window.location.href="<?=$_SESSION["URL_PORTAL"]."index.php"?>"</script><?
	exit;
}
//error_reporting(E_ALL);
require("Spreadsheet/Excel/Classes/PHPExcel.php");
require "Spreadsheet/Excel/Classes/PHPExcel/IOFactory.php";


$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Portal Proveedores")
							 ->setLastModifiedBy("Portal Proveedores")
							 ->setTitle("Office 2007 XLSX")
							 ->setSubject("Office 2007 XLSX")
							 ->setDescription("Document for Office 2007 XLSX")
							 ->setKeywords("office 2007")
							 ->setCategory("Result file");


include "hojaExcel.php";

$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$_POST['file_name'].'.xlsx"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
//$objWriter->save('test.xls');
?>