本文整理汇总了PHP中PHPExcel_Style类的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Style类的具体用法?PHP PHPExcel_Style怎么用?PHP PHPExcel_Style使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPExcel_Style类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$this->load->model('Juego_model');
$rs = $this->Juego_model->get_entries();
foreach ($rs as $key => $value) {
$rs[$key]['total_incorrectas'] = (int) $value['puntos_total'] - (int) $value['puntos'];
$rs[$key]['more'] = $this->Juego_model->get_entries_detalle($value['id_juego']);
}
$this->load->library('Excel');
//$this->excel->setActiveSheetIndex(0);
$objPHPExcel = $this->excel;
// set hoja 2
$objPHPExcel = $this->_reportDetalle($objPHPExcel, $rs);
$sheet = $objPHPExcel->getSheet(1);
// Sheet 1
$objPHPExcel->getProperties()->setCreator("PLATICOM")->setLastModifiedBy("PLATICOM")->setTitle("REGISTROS PLATICOM-RESPONDE")->setSubject("REGISTROS PLATICOM-RESPONDE")->setDescription("REGISTROS PLATICOM-RESPONDE")->setKeywords("REGISTROS PLATICOM-RESPONDE")->setCategory("plataticom-records");
$tituloReporte = "REGISTROS PLATICOM-PLAY";
$titulosColumnas = array('INDICE', 'CODIGO USUARIO', 'RPTA CORRECTAS', 'RPTA INCORRECTAS', 'TOTAL PREGUNTAS', 'FECHA', '.', '.');
// set headers *excel*
$sheet->mergeCells('A1:E2');
$sheet->setCellValue('A1', $tituloReporte)->setCellValue('A4', $titulosColumnas[0])->setCellValue('B4', $titulosColumnas[1])->setCellValue('C4', $titulosColumnas[2])->setCellValue('D4', $titulosColumnas[3])->setCellValue('E4', $titulosColumnas[4])->setCellValue('F4', $titulosColumnas[5])->setCellValue('G4', $titulosColumnas[6])->setCellValue('H4', $titulosColumnas[7]);
// print data
$i = 5;
$contador = 1;
foreach ($rs as $item) {
$sheet->setCellValue('A' . $i, $contador)->setCellValue('B' . $i, $item['codigo_usuario'])->setCellValue('C' . $i, $item['puntos'])->setCellValue('D' . $i, $item['total_incorrectas'])->setCellValue('E' . $i, $item['puntos_total'])->setCellValue('F' . $i, $item['fecha_fin']);
$i++;
$contador++;
}
// STYLE EXCEL
$estiloTituloReporte = array('font' => array('name' => 'Verdana', 'bold' => true, 'italic' => false, 'strike' => false, 'size' => 16, 'color' => array('rgb' => 'FFFFFF')), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FF244062')), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_NONE)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'rotation' => 0, 'wrap' => TRUE));
$estiloTituloColumnas = array('font' => array('name' => 'Arial', 'bold' => true, 'size' => '11', 'color' => array('rgb' => 'FFFFFF')), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFA5A5A5')), 'borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM, 'color' => array('rgb' => '143860')), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM, 'color' => array('rgb' => '143860')), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM, 'color' => array('rgb' => '143860'))), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'wrap' => TRUE));
$estiloInformacion = new PHPExcel_Style();
$estiloInformacion->applyFromArray(array('font' => array('name' => 'Arial', 'color' => array('rgb' => '000000')), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFDCE6F1')), 'borders' => array('right' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('rgb' => '3a2a47')), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('rgb' => '3a2a47')))));
$sheet->getStyle('A1:E2')->applyFromArray($estiloTituloReporte);
$sheet->getStyle('A4:H4')->applyFromArray($estiloTituloColumnas);
$sheet->setSharedStyle($estiloInformacion, "A5:H" . ($i - 1));
$sheet->getColumnDimension('A')->setWidth(5);
$sheet->getColumnDimension('B')->setWidth(15);
$sheet->getColumnDimension('C')->setWidth(20);
$sheet->getColumnDimension('D')->setWidth(20);
$sheet->getColumnDimension('E')->setWidth(20);
$sheet->getColumnDimension('F')->setWidth(20);
$sheet->getColumnDimension('G')->setWidth(20);
$sheet->getColumnDimension('H')->setWidth(20);
// PRINT EXCEL
$fecha = date('d-m-Y');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . __FUNCTION__ . '-' . $fecha . '.xls"');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Content-Type: text/html; charset=UTF-8');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
// always modified
header('Cache-Control: cache, must-revalidate');
// HTTP/1.1
header('Pragma: public');
// HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
示例2: _signupSheet
protected function _signupSheet($event, $includeEndingTerms, $includeNotEndingTerms)
{
$sheet = new PHPExcel_Worksheet($this->_excelDoc, 'Signup Sheet for Workshop ' . $event['workshopTitle']);
// Set up the margins so the header doesn't bleed into the page
$sheet->getPageMargins()->setTop(1.5);
// Make a three column page layout
$sheet->getColumnDimension('A')->setWidth(16);
$sheet->getColumnDimension('B')->setWidth(16);
$sheet->getColumnDimension('C')->setWidth(45);
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/config.xml', 'production');
$date = new DateTime($event['date']);
$startTime = new DateTime($event['startTime']);
$endTime = new DateTime($event['endTime']);
// Set the header on odd pages.
// The code formatting is off because the header doesn't ignore spaces.
/*
* Format:
* Title
* Room name
* date('D, M d, Y') (startTime('g:i A') - endTime('g:i A'))
* Instructors
*
*/
$sheet->getHeaderFooter()->setOddHeader('&C&B&14' . $event['workshopTitle'] . '&14&B&12 ' . chr(10) . $event['location'] . chr(10) . $date->format('l, M d, Y') . '(' . $startTime->format('g:i A') . ' - ' . $endTime->format('g:i A') . ')' . chr(10) . 'Instructor: ' . implode(',', $event['instructors']) . '&12&C');
// Write Column Headers for the table
$sheet->setCellValue('A1', 'First Name');
$sheet->setCellValue('B1', 'Last Name');
$sheet->setCellValue('C1', 'Signature');
// reformat it a little bit in a simpler way for us to use it in our
// spreadsheet printin' loop
$rows = array();
foreach ($event['attendeeList'] as $a) {
$rows[] = array($a['firstName'], $a['lastName']);
}
$signin = new PHPExcel_Style();
$signin->applyFromArray(array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN))));
$rowCounter = 3;
foreach ($rows as $row) {
$row = array_values($row);
// put the totals in the row
$char = self::A;
foreach ($row as $cell) {
$sheet->setCellValue(chr($char) . $rowCounter, $cell);
$char++;
}
$rowCounter++;
}
$tableHeaderStyle = new PHPExcel_Style();
$tableHeaderStyle->applyFromArray($this->_tableHeaderStyleArray);
$tableBodyStyle = new PHPExcel_Style();
$tableBodyStyle->applyFromArray($this->_contentStyleArray);
$sheet->setSharedStyle($tableHeaderStyle, 'A1:C1');
$sheet->setSharedStyle($tableBodyStyle, 'A3:B' . ($rowCounter - 1));
$sheet->setSharedStyle($signin, 'C3:C' . ($rowCounter - 1));
return $sheet;
}
示例3: generateDocument
/**
* (non-PHPdoc)
* @see \scipper\Datatransfer\TransferService::generateEmptyDocument()
*/
public function generateDocument(Map $map)
{
if (!class_exists("PHPExcel")) {
throw new GenerationException("dependency 'PHPExcel' not found");
}
$excel = new \PHPExcel();
$excel->removeSheetByIndex(0);
$excel->getProperties()->setCreator($map->getCreator());
$excel->getProperties()->setTitle($map->getTitle());
$protectedStyle = new \PHPExcel_Style();
$protectedStyle->applyFromArray(array("fill" => array("type" => \PHPExcel_Style_Fill::FILL_SOLID, "color" => array("argb" => "55CCCCCC")), "borders" => array("bottom" => array("style" => \PHPExcel_Style_Border::BORDER_THIN), "right" => array("style" => \PHPExcel_Style_Border::BORDER_MEDIUM))));
$i = 0;
foreach ($map->getSheets() as $sheet) {
$active = $excel->addSheet(new \PHPExcel_Worksheet(NULL, $sheet->getTitle()), $i);
$active->getProtection()->setSheet(true);
$active->getStyle("A1:Z30")->getProtection()->setLocked(\PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
foreach ($sheet->getCells() as $cell) {
//Convert content to list format ist necessary
if ($cell->getType() == "select") {
$dataValidation = $active->getCell($cell->getCoord())->getDataValidation();
$dataValidation->setType(\PHPExcel_Cell_DataValidation::TYPE_LIST);
$dataValidation->setAllowBlank(false);
$dataValidation->setShowInputMessage(true);
$dataValidation->setShowDropDown(true);
$dataValidation->setFormula1($cell->getContent());
} else {
$active->setCellValue($cell->getCoord(), $cell->getValue());
}
//Add protection is necessary
if ($cell->isProtected()) {
$active->protectCells($cell->getCoord(), "123");
$active->setSharedStyle($protectedStyle, $cell->getCoord());
// } elseif(!$cell->isProtected() && $active->getProtection()->isProtectionEnabled()) {
// $active->unprotectCells($cell->getCoord());
}
$active->getColumnDimension($cell->getX())->setAutoSize(true);
if (!$cell->isVisible()) {
$active->getColumnDimension($cell->getX())->setVisible(false);
}
}
$i++;
}
$excel->setActiveSheetIndex(0);
$writer = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
$filename = $this->documentRoot . $excel->getProperties()->getTitle() . ".xlsx";
$writer->save($filename);
return $filename;
}
示例4: setStyle
public function setStyle($cellRange, $fontFamily = 'Arial', $fontSize = 10, $colorRGB = '00000000', $bold = false, $italic = false, $underline = false)
{
require_once \GO::config()->root_path . 'go/vendor/PHPExcel/PHPExcel/Style.php';
require_once \GO::config()->root_path . 'go/vendor/PHPExcel/PHPExcel/Style/Font.php';
require_once \GO::config()->root_path . 'go/vendor/PHPExcel/PHPExcel/Style/Color.php';
$colorObj = new \PHPExcel_Style_Color();
$colorObj->setRGB($colorRGB);
$fontObj = new \PHPExcel_Style_Font();
$fontObj->setName($fontFamily);
$fontObj->setSize($fontSize);
$fontObj->setColor($colorObj);
$fontObj->setBold($bold);
$fontObj->setItalic($italic);
$fontObj->setUnderline($underline);
$styleObj = new \PHPExcel_Style();
$styleObj->setFont($fontObj);
$this->getActiveSheet()->setSharedStyle($styleObj, $cellRange);
}
示例5: propertyBeginBind
/**
* Property Begin Bind
*
* If no PHPExcel_Style_Protection has been bound to PHPExcel_Style then bind this one. Return the actual bound one.
*
* @return PHPExcel_Style_Protection
*/
private function propertyBeginBind() {
if(!isset($this->_parent))
return $this; // I am already bound
if($this->_parent->propertyIsBound($this->_parentPropertyName))
return $this->_parent->getProtection(); // Another one is already bound
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
$this->_parent = null;
return $this;
}
示例6: _initSharedStyles
/**
*
*/
protected function _initSharedStyles()
{
$headerTable = new PHPExcel_Style();
$rowEven = new PHPExcel_Style();
$rowOdd = new PHPExcel_Style();
$footerTable = new PHPExcel_Style();
$borders = array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FFDDDDDD')));
$alignment = array('wrap' => true, 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER);
$headerTable->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFFCFCFC')), 'borders' => $borders, 'font' => array('bold' => true), 'alignment' => $alignment));
$footerTable->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFFCFCFC')), 'borders' => $borders, 'font' => array('bold' => true), 'alignment' => $alignment, 'numberformat' => array('code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE)));
$rowEven->applyFromArray(array('borders' => $borders, 'alignment' => $alignment, 'numberformat' => array('code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE)));
$rowOdd->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFFCF9F9')), 'borders' => $borders, 'alignment' => $alignment, 'numberformat' => array('code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE)));
$this->_styles['table_header'] = $headerTable;
$this->_styles['table_footer'] = $footerTable;
$this->_styles['row_even'] = $rowEven;
$this->_styles['row_odd'] = $rowOdd;
}
示例7: date_default_timezone_set
date_default_timezone_set('Europe/London');
define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
/** Include PHPExcel */
require_once dirname(__FILE__) . '/../PHPExcel/PHPExcel.php';
// Create new PHPExcel object
echo date('H:i:s'), " Create new PHPExcel object", EOL;
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s'), " Set document properties", EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")->setLastModifiedBy("Maarten Balliauw")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file");
// Add some data
echo date('H:i:s'), " Add some data", EOL;
$objPHPExcel->setActiveSheetIndex(0);
$sharedStyle1 = new PHPExcel_Style();
$sharedStyle2 = new PHPExcel_Style();
$sharedStyle1->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFCCFFCC')), 'borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))));
$sharedStyle2->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFFFFF00')), 'borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))));
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle1, "A1:T100");
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, "C5:R95");
// Save Excel 2007 file
echo date('H:i:s'), " Write to Excel2007 format", EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s'), " File written to ", str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)), EOL;
echo 'Call time to write Workbook was ', sprintf('%.4f', $callTime), " seconds", EOL;
// Echo memory usage
echo date('H:i:s'), ' Current memory usage: ', memory_get_usage(true) / 1024 / 1024, " MB", EOL;
示例8: error_reporting
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
date_default_timezone_set('Europe/London');
define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
/** Include PHPExcel */
require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
echo date('H:i:s'), " Create new PHPExcel object", EOL;
$objPHPExcel = new PHPExcel();
$worksheet = $objPHPExcel->getActiveSheet();
echo date('H:i:s'), " Create styles array", EOL;
$styles = array();
for ($i = 0; $i < 10; $i++) {
$style = new PHPExcel_Style();
$style->getFont()->setSize($i + 4);
$styles[] = $style;
}
echo date('H:i:s'), " Add data (begin)", EOL;
$t = microtime(true);
for ($col = 0; $col < 50; $col++) {
for ($row = 0; $row < 100; $row++) {
$str = $row + $col;
$style = $styles[$row % 10];
$coord = PHPExcel_Cell::stringFromColumnIndex($col) . ($row + 1);
$worksheet->setCellValue($coord, $str);
$worksheet->duplicateStyle($style, $coord);
}
}
$d = microtime(true) - $t;
示例9: setDefaultStyle
/**
* Set default style - should only be used by PHPExcel_IReader implementations!
*
* @param PHPExcel_Style $value
* @throws Exception
*/
public function setDefaultStyle(PHPExcel_Style $value)
{
$this->_styles['default'] = $value;
// just a reference for PHPExcel_IWriter
PHPExcel_Style::setDefaultStyle($value);
}
示例10: array
// Se asignan las propiedades del libro
$objPHPExcel->getProperties()->setCreator("Codedrinks")->setLastModifiedBy("Codedrinks")->setTitle("Reporte de usuarios")->setSubject("Reporte Usuarios")->setDescription("Reporte de usuarios")->setKeywords("reporte de usuarios")->setCategory("Reporte excel");
$tituloReporte = "Relación de usuarios";
$titulosColumnas = array('User_ID', 'Name', 'Last Name', 'Telephone', 'Role', 'Status');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('A1:D1');
// Se agregan los titulos del reporte
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $tituloReporte)->setCellValue('A3', $titulosColumnas[0])->setCellValue('B3', $titulosColumnas[1])->setCellValue('C3', $titulosColumnas[2])->setCellValue('D3', $titulosColumnas[3])->setCellValue('E3', $titulosColumnas[4])->setCellValue('F3', $titulosColumnas[5]);
//Se agregan los datos de los alumnos
$i = 4;
while ($fila = $resultado->fetch_array()) {
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $i, $fila['User_ID'])->setCellValue('B' . $i, $fila['Name'])->setCellValue('C' . $i, $fila['Last_Name'])->setCellValue('D' . $i, utf8_encode($fila['Telephone']))->setCellValue('E' . $i, $fila['Role'])->setCellValue('F' . $i, utf8_encode($fila['Status']));
$i++;
}
$estiloTituloReporte = array('font' => array('name' => 'Verdana', 'bold' => true, 'italic' => false, 'strike' => false, 'size' => 16, 'color' => array('rgb' => 'FFFFFF')), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FF220835')), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_NONE)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'rotation' => 0, 'wrap' => TRUE));
$estiloTituloColumnas = array('font' => array('name' => 'Arial', 'bold' => true, 'color' => array('rgb' => 'FFFFFF')), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, 'startcolor' => array('rgb' => 'c47cf2'), 'endcolor' => array('argb' => 'FF431a5d')), 'borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM, 'color' => array('rgb' => '143860')), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM, 'rgb' => '143860')), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'wrap' => TRUE));
$estiloInformacion = new PHPExcel_Style();
$estiloInformacion->applyFromArray(array('font' => array('name' => 'Arial', 'color' => array('rgb' => '000000')), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFd9b7f4')), 'borders' => array('left' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('rgb' => '3a2a47')))));
$objPHPExcel->getActiveSheet()->getStyle('A1:F1')->applyFromArray($estiloTituloReporte);
$objPHPExcel->getActiveSheet()->getStyle('A3:F3')->applyFromArray($estiloTituloColumnas);
$objPHPExcel->getActiveSheet()->setSharedStyle($estiloInformacion, "A4:F" . ($i - 1));
for ($i = 'A'; $i <= 'F'; $i++) {
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension($i)->setAutoSize(TRUE);
}
// Se asigna el nombre a la hoja
$objPHPExcel->getActiveSheet()->setTitle('Alumnos');
// Se activa la hoja para que sea la que se muestre cuando el archivo se abre
$objPHPExcel->setActiveSheetIndex(0);
// Inmovilizar paneles
//$objPHPExcel->getActiveSheet(0)->freezePane('A4');
$objPHPExcel->getActiveSheet(0)->freezePaneByColumnAndRow(0, 4);
// Se manda el archivo al navegador web, con el nombre que se indica (Excel2007)
示例11: reporte_encuesta
/**
* Report encuesta
*/
public function reporte_encuesta()
{
$this->load->model('Encuesta_model');
$this->load->library('Excel');
$this->excel->setActiveSheetIndex(0);
$objPHPExcel = $this->excel;
$objPHPExcel->getProperties()->setCreator("PLATICOM")->setLastModifiedBy("PLATICOM")->setTitle("REGISTROS PLATICOM-RESPONDE")->setSubject("REGISTROS PLATICOM-RESPONDE")->setDescription("REGISTROS PLATICOM-RESPONDE")->setKeywords("REGISTROS PLATICOM-RESPONDE")->setCategory("plataticom-records");
$tituloReporte = "REGISTROS PLATICOM-ENCUESTA";
$titulosColumnas = array('N', 'USUARIO', 'PREGUNTA-1', 'PREGUNTA-2', 'PREGUNTA-3', 'PREGUNTA-4', 'PREGUNTA-5', 'FECHA');
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('A1:E2');
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $tituloReporte)->setCellValue('A4', $titulosColumnas[0])->setCellValue('B4', $titulosColumnas[1])->setCellValue('C4', $titulosColumnas[2])->setCellValue('D4', $titulosColumnas[3])->setCellValue('E4', $titulosColumnas[4])->setCellValue('F4', $titulosColumnas[5])->setCellValue('G4', $titulosColumnas[6])->setCellValue('H4', $titulosColumnas[7]);
$rs = $this->Encuesta_model->get_entries();
$i = 5;
$contador = 1;
foreach ($rs as $item) {
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $i, $contador)->setCellValue('B' . $i, $item['codigo_usuario']);
// 01
if (!empty($item['p1'])) {
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('C' . $i, $this->getOption(0, $item['p1']));
}
// 02
if (!empty($item['p2'])) {
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('D' . $i, $this->getOption(1, $item['p2']));
}
// 03
if (!empty($item['p3'])) {
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('E' . $i, $this->getOption(2, $item['p3']));
}
// 04
if (!empty($item['p4'])) {
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('F' . $i, $this->getOption(3, $item['p4']));
}
// 05
if (!empty($item['p5'])) {
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('G' . $i, $this->getOption(4, $item['p5']));
}
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('H' . $i, $item['fecha_fin']);
$i++;
$contador++;
}
// STYLE EXCEL
$estiloTituloReporte = array('font' => array('name' => 'Verdana', 'bold' => true, 'italic' => false, 'strike' => false, 'size' => 16, 'color' => array('rgb' => 'FFFFFF')), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FF244062')), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_NONE)), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'rotation' => 0, 'wrap' => TRUE));
$estiloTituloColumnas = array('font' => array('name' => 'Arial', 'bold' => true, 'size' => '11', 'color' => array('rgb' => 'FFFFFF')), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFA5A5A5')), 'borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM, 'color' => array('rgb' => '143860')), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM, 'color' => array('rgb' => '143860')), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM, 'color' => array('rgb' => '143860'))), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'wrap' => TRUE));
$estiloInformacion = new PHPExcel_Style();
$estiloInformacion->applyFromArray(array('font' => array('name' => 'Arial', 'color' => array('rgb' => '000000')), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFDCE6F1')), 'borders' => array('right' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('rgb' => '3a2a47')), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('rgb' => '3a2a47')))));
$objPHPExcel->getActiveSheet()->getStyle('A1:E2')->applyFromArray($estiloTituloReporte);
$objPHPExcel->getActiveSheet()->getStyle('A4:H4')->applyFromArray($estiloTituloColumnas);
$objPHPExcel->getActiveSheet()->setSharedStyle($estiloInformacion, "A5:H" . ($i - 1));
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('A')->setWidth(5);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(15);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('D')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('G')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('H')->setWidth(20);
// PRINT EXCEL
date_default_timezone_set("America/Lima");
$fecha = date('d-m-Y');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . __FUNCTION__ . '-' . $fecha . '.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Content-Type: text/html; charset=UTF-8');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
// always modified
header('Cache-Control: cache, must-revalidate');
// HTTP/1.1
header('Pragma: public');
// HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
示例12: setDefaultStyle
/**
* Set default style - should only be used by PHPExcel_IReader implementations!
*
* @param PHPExcel_Style $value
*/
public static function setDefaultStyle(PHPExcel_Style $value)
{
self::$_defaultStyle = $value;
}
示例13: reporteCarteraClientes
public function reporteCarteraClientes()
{
$idZona = $_REQUEST['lstZona'];
$idPadre = $_REQUEST['lstRegionCobranza'];
$idCategoria = $_REQUEST['lstCategoriaPrincipal'];
$idVendedor = $_REQUEST['idVendedor'];
$idCliente = $_REQUEST['idCliente'];
$idOrdenVenta = $_REQUEST['idOrdenVenta'];
$idDepartamento = $_REQUEST['lstDepartamento'];
$idProvincia = $_REQUEST['lstProvincia'];
$idDistrito = $_REQUEST['lstDistrito'];
$condicion = $_REQUEST['lstCondicion'];
$situacion = $_REQUEST['lstSituacion'];
$fechaInicio = !empty($_REQUEST['txtFechaInicio']) ? date('Y-m-d', strtotime($_REQUEST['txtFechaInicio'])) : "";
$fechaFin = !empty($_REQUEST['txtFechaFin']) ? date('Y-m-d', strtotime($_REQUEST['txtFechaFin'])) : "";
$condiciones = "";
if (strtolower($condicion) == "contado") {
$condiciones = " and ov.es_contado=1 and ov.es_credito!=1 and ov.es_letras!=1 ";
} elseif (strtolower($condicion) == "credito") {
$condiciones = " and ov.es_credito=1 and ov.es_letra!=1 ";
} elseif (strtolower($condicion) == "letras banco") {
$condiciones = " and ov.es_letras=1 and ov.tipo_letra=1 ";
} elseif (strtolower($condicion) == "letras cartera") {
$condiciones = " and ov.es_letras=1 and ov.tipo_letra=2 ";
}
//traemos los datos
$reporte = $this->AutoLoadModel('reporte');
$datos = $reporte->carteraClientes($idZona, $idPadre, $idCategoria, $idVendedor, $idCliente, $idOrdenVenta, $idDepartamento, $idProvincia, $idDistrito, $condiciones, $situacion, $fechaInicio, $fechaFin);
$cantidadData = count($datos);
//Creamos en nombre de archivo
$baseURL = ROOT . 'descargas' . DS;
$idActor = $_SESSION['idactor'];
$fechaCreacion = date('Y-m-d_h.m.s');
$basenombre = 'CarteraClientes.xls';
$filename = $baseURL . $idActor . '_' . $fechaCreacion . '_' . $basenombre;
//traemos la libreria de Excel e instanciamos
$this->AutoLoadLib('PHPExcel');
$objPHPExcel = new PHPExcel();
//llenamos los datos
$titulos = array('Orden Venta', 'FECHA', 'COD', 'CLIENTE', 'EMAIL', 'RUC', 'TELEFONO', 'IMPORTE ($/.)', 'DIRECCION', 'DISTRITO', 'DPTO');
//poniendo stylo al encabezado
//Lineas para cuadros
$sharedStyle1 = new PHPExcel_Style();
$sharedStyle1->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFCCFFCC')), 'borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))));
//estableciendo a automatico el ancho
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setAutoSize(true);
$importe = 0;
$zona = 0;
$cont = 0;
for ($i = 0; $i < $cantidadData; $i++) {
if ($zona != $datos[$i]['idzona']) {
$zona = $datos[$i]['idzona'];
if ($i != 0) {
$cont++;
}
$cont++;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $cont, $datos[$i]['nombrezona']);
$cont++;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $cont, $titulos[0])->setCellValue('B' . $cont, $titulos[1])->setCellValue('C' . $cont, $titulos[2])->setCellValue('D' . $cont, $titulos[3])->setCellValue('E' . $cont, $titulos[4])->setCellValue('F' . $cont, $titulos[5])->setCellValue('G' . $cont, $titulos[6])->setCellValue('H' . $cont, $titulos[7])->setCellValue('I' . $cont, $titulos[8])->setCellValue('J' . $cont, $titulos[9])->setCellValue('K' . $cont, $titulos[10]);
//negrita
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle1, "A" . $cont . ":K" . $cont);
//Negrita a los encabezados
$objPHPExcel->getActiveSheet()->getStyle("A" . $cont . ":K" . $cont)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle("A" . $cont . ":K" . $cont)->getFill()->setRotation(1);
}
$cont++;
$fila = array($datos[$i]['codigov'], $datos[$i]['fordenventa'], $datos[$i]['codantiguo'], html_entity_decode($datos[$i]['razonsocial'], ENT_QUOTES, 'UTF-8'), utf8_decode(html_entity_decode($datos[$i]['email'], ENT_QUOTES, 'UTF-8')), $datos[$i]['ruc'], $datos[$i]['telefono'], number_format($datos[$i]['importeov'], 2), utf8_decode(html_entity_decode($datos[$i]['direccion'], ENT_QUOTES, 'UTF-8')), html_entity_decode($datos[$i]['nombredistrito'], ENT_QUOTES, 'UTF-8'), html_entity_decode($datos[$i]['nombredepartamento'], ENT_QUOTES, 'UTF-8'));
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $cont, $datos[$i]['codigov'])->setCellValue('B' . $cont, $datos[$i]['fordenventa'])->setCellValue('C' . $cont, $datos[$i]['codantiguo'])->setCellValue('D' . $cont, html_entity_decode($datos[$i]['razonsocial'], ENT_QUOTES, 'UTF-8'))->setCellValue('E' . $cont, utf8_decode(html_entity_decode($datos[$i]['email'], ENT_QUOTES, 'UTF-8')))->setCellValue('F' . $cont, $datos[$i]['ruc'])->setCellValue('G' . $cont, $datos[$i]['telefono'])->setCellValue('H' . $cont, round($datos[$i]['importeov'], 2))->setCellValue('I' . $cont, utf8_decode(html_entity_decode($datos[$i]['direccion'], ENT_QUOTES, 'UTF-8')))->setCellValue('J' . $cont, html_entity_decode($datos[$i]['nombredistrito'], ENT_QUOTES, 'UTF-8'))->setCellValue('K' . $cont, html_entity_decode($datos[$i]['nombredepartamento'], ENT_QUOTES, 'UTF-8'));
$importe += round($datos[$i]['importeov'], 4);
}
$objPHPExcel->getActiveSheet()->setTitle('Reporte_Cartera_Clientes');
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save($filename);
header('Content-Description: File Transfer');
header('Content-type: application/force-download');
header('Content-Disposition: attachment; filename=' . basename($filename));
header('Content-Transfer-Encoding: binary');
header("Content-type: application/octet-stream");
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
ob_clean();
flush();
readfile($filename);
unlink($filename);
}
示例14: _writeCellStyleDxf
/**
* Write Cell Style Dxf
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_Style $pStyle Style
* @throws Exception
*/
private function _writeCellStyleDxf(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style $pStyle = null)
{
// dxf
$objWriter->startElement('dxf');
// font
$this->_writeFont($objWriter, $pStyle->getFont());
// numFmt
$this->_writeNumFmt($objWriter, $pStyle->getNumberFormat());
// fill
$this->_writeFill($objWriter, $pStyle->getFill());
// alignment
$objWriter->startElement('alignment');
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
$textRotation = 0;
if ($pStyle->getAlignment()->getTextRotation() >= 0) {
$textRotation = $pStyle->getAlignment()->getTextRotation();
} else {
if ($pStyle->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
}
}
$objWriter->writeAttribute('textRotation', $textRotation);
$objWriter->endElement();
// border
$this->_writeBorder($objWriter, $pStyle->getBorders());
// protection
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('locked', $pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false');
}
if ($pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('hidden', $pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false');
}
$objWriter->endElement();
}
$objWriter->endElement();
}
示例15: PHPExcel_Style
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(16.14);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(23);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(11);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(6.86);
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(7.43);
$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(6.29);
$objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(15.29);
$objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(11.1);
// Set autofilter
// Always include the complete filter range!
// Excel does support setting only the caption
// row, but that's not a best practise...
$objPHPExcel->getActiveSheet()->setAutoFilter($objPHPExcel->getActiveSheet()->calculateWorksheetDimension());
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
$sharedStyle1 = new PHPExcel_Style();
$sharedStyle2 = new PHPExcel_Style();
$sharedStyle1->applyFromArray(array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'left' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))));
$objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle1, "A7:M{$nox}");
// Set style for header row using alternative method
$objPHPExcel->getActiveSheet()->getStyle('A7:M7')->applyFromArray(array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT), 'borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, 'startcolor' => array('argb' => 'FFA0A0A0'), 'endcolor' => array('argb' => 'FFFFFFFF'))));
// Add a drawing to the worksheet
//$objDrawing = new PHPExcel_Worksheet_Drawing();
//$objDrawing->setName('Logo');
//$objDrawing->setDescription('Logo');
//$objDrawing->setPath('../images/logo2.png');
//$objDrawing->setCoordinates('B2');
//$objDrawing->setHeight(120);
//$objDrawing->setWidth(120);
//$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objPHPExcel->getActiveSheet()->getStyle('A7:M1000')->getFont()->setName('Arial');