/
descargar_informacion.php
51 lines (42 loc) · 1.72 KB
/
descargar_informacion.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
//ChromePhp::log('1');
require_once 'Classes/PHPExcel.php';
//ChromePhp::log('a');
$info_empresas = getInfoEmpresas();
$objPHPExcel = new PHPExcel();
//Informacion del excel
$objPHPExcel->
getProperties()
->setCreator("RhConectium")
->setLastModifiedBy("RhConectium")
->setTitle("Informacion Empresas")
->setSubject("Informacion Empresas")
->setDescription("Documento generado con PHPExcel")
->setKeywords("RhConectium")
->setCategory("RhConectium");
$i = 2;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1','EMPRESA')
->setCellValue('B1','VOTOS POSITIVOS')
->setCellValue('C1','VOTOS NEGATIVOS')
->setCellValue('D1','MENSAJES')
->setCellValue('E1','RESPUESTAS');
foreach ($info_empresas as $empresa) {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A'.$i, $empresa['nombre'])
->setCellValue('B'.$i, $empresa['votos']['votos_positivos'])
->setCellValue('C'.$i, $empresa['votos']['votos_negativos'])
->setCellValue('D'.$i, $empresa['comentarios']['comentarios_usuarios'])
->setCellValue('E'.$i, $empresa['comentarios']['respuestas']);
$i++;
}
//ChromePhp::log('C');
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header('Content-Disposition: attachment; filename="info_empresas'.time().'.xlsx"');
header('Cache-Control: max-age=0');
$writer = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$writer->save('php://output');
ChromePhp::log('b');
?>