Skip to content

Instantly share code, notes, and snippets.

@bvelastegui
Last active July 18, 2017 14:48
Show Gist options
  • Save bvelastegui/b25a20e4f61ea0a560a44ee7c1dfad98 to your computer and use it in GitHub Desktop.
Save bvelastegui/b25a20e4f61ea0a560a44ee7c1dfad98 to your computer and use it in GitHub Desktop.
<?php
$excel = new PHPExcel();
//Usamos el worsheet por defecto
$sheet = $excel->getActiveSheet();
//Agregamos un texto a la celda A1
$sheet->setCellValue('A1', 'Prueba');
//Damos formato o estilo a nuestra celda
$sheet->getStyle('A1')->getFont()->setName('Tahoma')->setBold(true)->setSize(8);
$sheet->getStyle('A1')->getBorders()->applyFromArray(array('allBorders' => 'thin'));
$sheet->getStyle('A1')->getAlignment()->setVertical('center')->setHorizontal('center');
$sheet->setCellValue('B1', 'PHPExcel');
//usamos los mismos estilos de A1
$sheet->getStyle('B1')->getFont()->setName('Tahoma')->setBold(true)->setSize(8);
$sheet->getStyle('B1')->getBorders()->applyFromArray(array('allBorders' => 'thin'));
$sheet->getStyle('B1')->getAlignment()->setVertical('center')->setHorizontal('center');
//exportamos nuestro documento
$writer = new PHPExcel_Writer_Excel5($excel);
$writer->save('prueba.xls');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment