<?php

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

$sql= "SELECT * from correos";

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

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

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


$objPHPExcel->getActiveSheet()->setCellValue('A1', 'ID');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'NOMBRE');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'SUCURSAL');
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'CORREO');
$objPHPExcel->getActiveSheet()->setCellValue('E1', 'CLAVE CORREO');



while($row= $resultado->fetch_assoc())
{
	$objPHPExcel->getActiveSheet()->setCellValue('A'.$fila, $row['id']);
	$objPHPExcel->getActiveSheet()->setCellValue('B'.$fila, $row['nombreu']);
	$objPHPExcel->getActiveSheet()->setCellValue('E'.$fila, $row['sucursal']);
	$objPHPExcel->getActiveSheet()->setCellValue('L'.$fila, $row['correo']);
	$objPHPExcel->getActiveSheet()->setCellValue('M'.$fila, $row['password']);

	$fila++;
}

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

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