<?php

require 'Classes/PHPExcel.php';
require 'cn2.php';

$sql= "SELECT * from v_phone";

$resultado = $mysqli->query($sql);
$fila=2;

$objPHPExcel= new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Sistemas Volvo Minerva")->
setDescription("Reporte Inventario VOLVO Celulares");

$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setTitle("Celulares");


$objPHPExcel->getActiveSheet()->setCellValue('A1', 'ID');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'USUARIO');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'SUCURSAL');
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'AREA');
$objPHPExcel->getActiveSheet()->setCellValue('E1', 'SERIE');
$objPHPExcel->getActiveSheet()->setCellValue('F1', 'MODELO');
$objPHPExcel->getActiveSheet()->setCellValue('G1', 'IMEI');
$objPHPExcel->getActiveSheet()->setCellValue('H1', 'NUMERO');



while($row= $resultado->fetch_assoc())
{
	$objPHPExcel->getActiveSheet()->setCellValue('A'.$fila, $row['t_id']);
	$objPHPExcel->getActiveSheet()->setCellValue('B'.$fila, $row['t_user']);
	$objPHPExcel->getActiveSheet()->setCellValue('C'.$fila, $row['t_sucursal']);
	$objPHPExcel->getActiveSheet()->setCellValue('D'.$fila, $row['t_area']);
	$objPHPExcel->getActiveSheet()->setCellValue('E'.$fila, $row['t_serie']);
	$objPHPExcel->getActiveSheet()->setCellValue('F'.$fila, $row['t_modelo']);
    $objPHPExcel->getActiveSheet()->setCellValue('G'.$fila, $row['t_imei']);
    $objPHPExcel->getActiveSheet()->setCellValue('H'.$fila, $row['t_num']);


	$fila++;
}

header("Content-Type:
	application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header('Content-Disposition: attachment;filename="report_celulares.xlsx"');
header('Cache-Control: max-age=0');

$objWriter= new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('php://output');
?>