当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel::getDefaultStyle方法代码示例

本文整理汇总了PHP中PHPExcel::getDefaultStyle方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel::getDefaultStyle方法的具体用法?PHP PHPExcel::getDefaultStyle怎么用?PHP PHPExcel::getDefaultStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPExcel的用法示例。


在下文中一共展示了PHPExcel::getDefaultStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Create a new PHPExcel_Writer_HTML
  *
  * @param 	PHPExcel	$phpExcel	PHPExcel object
  */
 public function __construct(PHPExcel $phpExcel)
 {
     $this->_phpExcel = $phpExcel;
     $this->_defaultFontSize = $this->_phpExcel->getDefaultStyle()->getFont()->getSize();
     $this->_sheetIndex = 0;
     $this->_imagesRoot = '.';
 }
开发者ID:linhanwei,项目名称:TP,代码行数:12,代码来源:HTML.php

示例2: setDefaultStyle

	/**
	 * Set default style - should only be used by PHPExcel_IReader
	 * implementations!
	 *
	 * @deprecated
	 *
	 * @param PHPExcel_Style $value        	
	 * @throws Exception
	 * @return PHPExcel_Worksheet
	 */
	public function setDefaultStyle(PHPExcel_Style $pValue) {
		$this->_parent->getDefaultStyle ()->applyFromArray ( array (
				'font' => array (
						'name' => $pValue->getFont ()->getName (),
						'size' => $pValue->getFont ()->getSize () 
				) 
		) );
		return $this;
	}
开发者ID:nanpeixoto,项目名称:cide,代码行数:19,代码来源:Worksheet.php

示例3: getPHPExcelObject

 private function getPHPExcelObject()
 {
     $excelWriter = new PHPExcel();
     $excelWriter->setActiveSheetIndex(0);
     /* set HORIZONTAL_CENTER for the whole sheet */
     $excelWriter->getDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     /* set VERTICAL_CENTER for the whole sheet */
     $excelWriter->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     return $excelWriter;
 }
开发者ID:FantasticThought,项目名称:tfsda,代码行数:10,代码来源:excel.class.php

示例4: render

 /**
  *
  */
 public function render()
 {
     $excel = new \PHPExcel();
     $excel->getDefaultStyle()->getFont()->setName('Arial');
     $excel->getDefaultStyle()->getFont()->setSize(10);
     $this->_sheet = $excel->getActiveSheet();
     $this->_sheet->setTitle($this->_tabs_title);
     $this->_sheet->getTabColor()->setARGB('FFc3e59e');
     $this->_sheet->fromArray($this->makeExportData());
     //resize
     $this->excelWidth();
     //height header
     header('Content-Type: application/excel');
     header('Content-Disposition: attachment; filename="' . $this->getFile() . '"');
     header('Cache-Control: max-age=0');
     $writer = new \PHPExcel_Writer_Excel2007($excel);
     $writer->save('php://output');
 }
开发者ID:defan-marunchak,项目名称:eurotax,代码行数:21,代码来源:Excel.php

示例5: export

 public function export()
 {
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     $phpExcelPath = Yii::getPathOfAlias('application.vendors');
     include $phpExcelPath . DIRECTORY_SEPARATOR . 'PHPExcel.php';
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->setActiveSheetIndex(0);
     // Set style for column name
     $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
     $objPHPExcel->getDefaultStyle()->getFont()->setSize(10);
     $rows = 1;
     $totalColumn = count($this->attribute);
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $rows, $this->title)->mergeCellsByColumnAndRow(0, 1, $totalColumn - 1, 1);
     $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(0, $rows)->getFont()->setBold(true)->setSize(14);
     $rows++;
     $i = 0;
     foreach ($this->attribute as $key => $value) {
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, $rows, $value);
         $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($i, $rows)->getFont()->setBold(true)->setSize(10);
         $i++;
     }
     $rows++;
     for ($i = 0; $i <= $totalColumn; $i++) {
         $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($i)->setAutoSize(true);
     }
     foreach ($this->dataSoure as $data) {
         $i = 0;
         foreach ($this->attribute as $key => $value) {
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($i, $rows, $data[$key]);
             $i++;
         }
         $rows++;
     }
     $fileName = $this->title . "-" . date('Ymd', time()) . '.xls';
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="' . $fileName . '"');
     header('Cache-Control: max-age=0');
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     $objWriter->save('php://output');
     Yii::app()->end();
     spl_autoload_register(array('YiiBase', 'autoload'));
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:42,代码来源:ExcelExport.php

示例6: dump

 /**
  * Dumps the stats table
  * @param  StatsTable $statsTable
  * @return string
  */
 public function dump(StatsTable $statsTable)
 {
     $excel = new \PHPExcel();
     $excel->getDefaultStyle()->applyFromArray($this->getDefaultStyleArray());
     $sheet = $excel->getSheet();
     $row = 1;
     $data = $statsTable->getData();
     $width = count(reset($data));
     // HEADERS //
     if ($this->enableHeaders) {
         $headerStyle = new \PHPExcel_Style();
         $headerStyle->applyFromArray($this->getHeadersStyleArray());
         $col = 0;
         foreach ($statsTable->getHeaders() as $header) {
             $sheet->setCellValueByColumnAndRow($col, $row, $header);
             $col++;
         }
         $sheet->duplicateStyle($headerStyle, 'A1:' . \PHPExcel_Cell::stringFromColumnIndex($width - 1) . '1');
         $row++;
     }
     // DATA //
     foreach ($statsTable->getData() as $data) {
         $this->applyValues($sheet, $row, $data, $statsTable->getDataFormats());
         $row++;
     }
     // AGGREGATIONS //
     if ($this->enableAggregation) {
         $this->applyValues($sheet, $row, $statsTable->getAggregations(), $statsTable->getAggregationsFormats(), $this->getAggregationsStyleArray());
     }
     // FINAL FORMATTING //
     for ($col = 0; $col < $width; $col++) {
         $sheet->getColumnDimension(\PHPExcel_Cell::stringFromColumnIndex($col))->setAutoSize(true);
     }
     $xlsDumper = new \PHPExcel_Writer_Excel2007($excel);
     $pFilename = @tempnam(\PHPExcel_Shared_File::sys_get_temp_dir(), 'phpxltmp');
     $xlsDumper->save($pFilename);
     $contents = file_get_contents($pFilename);
     @unlink($pFilename);
     unset($excel);
     unset($xlsDumper);
     return $contents;
 }
开发者ID:igraal,项目名称:stats-table,代码行数:47,代码来源:ExcelDumper.php

示例7: array_to_spreadsheet

function array_to_spreadsheet($arr)
{
    $CI =& get_instance();
    PHPExcel_Shared_File::setUseUploadTempDirectory(true);
    $objPHPExcel = new PHPExcel();
    //Default all cells to text
    $objPHPExcel->getDefaultStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
    for ($k = 0; $k < count($arr); $k++) {
        for ($j = 0; $j < count($arr[$k]); $j++) {
            $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($j, $k + 1, $arr[$k][$j]);
        }
    }
    if ($CI->config->item('spreadsheet_format') == 'XLSX') {
        $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
    } else {
        $objWriter = new PHPExcel_Writer_CSV($objPHPExcel);
    }
    ob_start();
    $objWriter->save('php://output');
    $excelOutput = ob_get_clean();
    return $excelOutput;
}
开发者ID:ekchanthorn,项目名称:demo_loan,代码行数:22,代码来源:spreadsheet_helper.php

示例8: reporteNewExcel

function reporteNewExcel($fec1, $fec2)
{
    global $db;
    // Incluir la libreria PHPExcel
    require '../include/PHPExcel/PHPExcel.php';
    // Reservar memoria en servidor PHP
    //   Si el archivo final tiene 5Mb, reservar 500Mb
    //   Por cada operación, phpExcel mapea en memoria la imagen del archivo y esto satura la mamoria
    ini_set("memory_limit", "512M");
    // Create a new PHPExcel object
    $objPHPExcel = new PHPExcel();
    $objPHPExcel->getActiveSheet()->setTitle('Hoja 1');
    $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
    $objPHPExcel->getDefaultStyle()->getFont()->setSize(8);
    // Estilos Arreglo
    $styleEnc = array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER), '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')));
    $styleSombra = 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' => '80E9E07A'), 'endcolor' => array('argb' => 'FFFFFFFF')));
    $styleTitulo = array('font' => array('bold' => true, 'size' => 14), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT));
    $styleSubtitulo = array('font' => array('bold' => true, 'size' => 10), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT));
    // ----------------------------
    // Se aplica estilo al encabezado
    $objPHPExcel->getActiveSheet()->getStyle('A5:E5')->applyFromArray($styleEnc);
    // Encabezados
    $headings = array('User Name', 'Login', 'Email');
    // Escribe los encabezados
    $rowNumber = 5;
    $col = 'A';
    foreach ($headings as $heading) {
        $objPHPExcel->getActiveSheet()->setCellValue($col . $rowNumber, $heading);
        $col++;
    }
    // AutoFiltro
    $objPHPExcel->getActiveSheet()->setAutoFilter('A5:C5');
    // Auto Ajuste de Ancho en Columna
    $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(30);
    $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
    $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
    $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
    // Freeze pane so that the heading line won't scroll
    $objPHPExcel->getActiveSheet()->freezePane('A6');
    // Titulo
    $objPHPExcel->getActiveSheet()->setCellValue('A1', 'MOPSA S.A. DE C.V.')->getStyle('A1')->applyFromArray($styleTitulo);
    // SUBTitulo
    $objPHPExcel->getActiveSheet()->setCellValue('A2', 'Reporte de ...');
    $objPHPExcel->getActiveSheet()->getStyle('A2')->applyFromArray($styleSubtitulo);
    // Simple query
    $sql = "SELECT * from USUARIO";
    $db->query($sql);
    // Escribe los Registros
    $rowNumber = 6;
    while ($db->next_record()) {
        /*// Se arman las columnas con los datos.
                $rowF[0]= $db->f(Nombre);
                $rowF[1]= $db->f(Login);
                $rowF[2]= $db->f(Email);
        
                $col = 'A';                    
                foreach($rowF as $cell) { 
                    $objPHPExcel->getActiveSheet()->setCellValue($col.$rowNumber,$cell); 
        
                    // Sombra en registro
                    //$objPHPExcel->getActiveSheet()->getStyle($col.$rowNumber)->applyFromArray($styleSombra);                
        
                    $col++; 
                }
                unset($rowF)
                */
        // Por manejo de memoria se deben de meter los datos con las menos operaciones posibles.
        $objPHPExcel->getActiveSheet()->setCellValue('A' . $rowNumber, $db->f(usuario))->setCellValue('B' . $rowNumber, $db->f(login))->setCellValue('C' . $rowNumber, $db->f(id_usuario));
        $rowNumber++;
    }
    // Se modifican los encabezados del HTTP para indicar que se envia un archivo de Excel2007.
    header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    header('Content-Disposition:attachment;filename="Report.xlsx"');
    header('Cache-Control: max-age=0');
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
    $objWriter->save('php://output');
    exit;
}
开发者ID:nesmaster,项目名称:mopsapro,代码行数:79,代码来源:plantillaPHPExcel.php

示例9: _writeCellStyleXf

 /**
  * Write Cell Style Xf
  *
  * @param 	PHPExcel_Shared_XMLWriter			$objWriter 		XML Writer
  * @param 	PHPExcel_Style						$pStyle			Style
  * @param 	PHPExcel							$pPHPExcel		Workbook
  * @throws 	Exception
  */
 private function _writeCellStyleXf(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style $pStyle = null, PHPExcel $pPHPExcel = null)
 {
     // xf
     $objWriter->startElement('xf');
     $objWriter->writeAttribute('xfId', 0);
     $objWriter->writeAttribute('fontId', (int) $this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode()));
     if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) {
         $objWriter->writeAttribute('numFmtId', (int) ($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164));
     } else {
         $objWriter->writeAttribute('numFmtId', (int) $pStyle->getNumberFormat()->getBuiltInFormatCode());
     }
     $objWriter->writeAttribute('fillId', (int) $this->getParentWriter()->getFillHashTable()->getIndexForHashCode($pStyle->getFill()->getHashCode()));
     $objWriter->writeAttribute('borderId', (int) $this->getParentWriter()->getBordersHashTable()->getIndexForHashCode($pStyle->getBorders()->getHashCode()));
     // Apply styles?
     $objWriter->writeAttribute('applyFont', $pPHPExcel->getDefaultStyle()->getFont()->getHashCode() != $pStyle->getFont()->getHashCode() ? '1' : '0');
     $objWriter->writeAttribute('applyNumberFormat', $pPHPExcel->getDefaultStyle()->getNumberFormat()->getHashCode() != $pStyle->getNumberFormat()->getHashCode() ? '1' : '0');
     $objWriter->writeAttribute('applyFill', $pPHPExcel->getDefaultStyle()->getFill()->getHashCode() != $pStyle->getFill()->getHashCode() ? '1' : '0');
     $objWriter->writeAttribute('applyBorder', $pPHPExcel->getDefaultStyle()->getBorders()->getHashCode() != $pStyle->getBorders()->getHashCode() ? '1' : '0');
     $objWriter->writeAttribute('applyAlignment', $pPHPExcel->getDefaultStyle()->getAlignment()->getHashCode() != $pStyle->getAlignment()->getHashCode() ? '1' : '0');
     if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
         $objWriter->writeAttribute('applyProtection', 'true');
     }
     // 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->writeAttribute('wrapText', $pStyle->getAlignment()->getWrapText() ? 'true' : 'false');
     $objWriter->writeAttribute('shrinkToFit', $pStyle->getAlignment()->getShrinkToFit() ? 'true' : 'false');
     if ($pStyle->getAlignment()->getIndent() > 0) {
         $objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent());
     }
     $objWriter->endElement();
     // 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();
 }
开发者ID:echoOly,项目名称:php_base,代码行数:62,代码来源:Style.php

示例10: price

$objPHPExcel->getActiveSheet()->SetCellValue('A6', '');
$objPHPExcel->getActiveSheet()->SetCellValue('B6', 'All Categories');
$objPHPExcel->getActiveSheet()->SetCellValue('C6', $root_sales_detail->quantity);
$objPHPExcel->getActiveSheet()->SetCellValue('D6', '');
$objPHPExcel->getActiveSheet()->SetCellValueExplicit('E6', price(CURRENCY, $root_sales_detail->subtotal), PHPExcel_Cell_DataType::TYPE_STRING);
if ($root_sales_detail->discount != 0) {
    $objPHPExcel->getActiveSheet()->SetCellValueExplicit('F6', "-" . price(CURRENCY, $root_sales_detail->discount), PHPExcel_Cell_DataType::TYPE_STRING);
}
$objPHPExcel->getActiveSheet()->SetCellValueExplicit('G6', price(CURRENCY, $root_sales_detail->subtotal - $root_sales_detail->discount), PHPExcel_Cell_DataType::TYPE_STRING);
$objPHPExcel->getActiveSheet()->getStyle('A6:G6')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('A6:G6')->getFill()->applyFromArray(array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'bbbbbb')));
//rows
$rowxls = 6;
$_get->print_category_xls($iteration, 'top', 0);
//format cell
$objPHPExcel->getDefaultStyle()->getFont()->setName('Helvetica')->setSize(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(60);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
//title
$objPHPExcel->getActiveSheet()->getStyle('A1:G3')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('A1:A3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//header row
$objPHPExcel->getActiveSheet()->getStyle('A5:G5')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
$objPHPExcel->getActiveSheet()->getStyle('A5:G5')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('A5:G5')->getFill()->applyFromArray(array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => '000000')));
$objPHPExcel->getActiveSheet()->getStyle('A5:G5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
开发者ID:nickyudha,项目名称:spalosophy,代码行数:31,代码来源:export.php

示例11: reporte

function reporte($fec1, $fec2)
{
    global $connI;
    $reportName = "Intermodal :: Rep. Hojas de Instruccion en MscLink";
    // Incluir la libreria PHPExcel
    require '../include/PHPExcel/PHPExcel.php';
    // Reservar memoria en servidor PHP
    //   Si el archivo final tiene 5Mb, reservar 500Mb
    //   Por cada operación, phpExcel mapea en memoria la imagen del archivo y esto satura la mamoria
    ini_set("memory_limit", "512M");
    // Estilos Arreglo
    $styleEnc = array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER), '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')));
    $styleSombra = 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' => '80E9E07A'), 'endcolor' => array('argb' => 'FFFFFFFF')));
    $styleTitulo = array('font' => array('bold' => true, 'size' => 14), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT));
    $styleSubtitulo = array('font' => array('bold' => true, 'size' => 10), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT));
    // ----------------------------
    // Hoja 1
    // Nota : No usar acentos!!!
    $objPHPExcel = new PHPExcel();
    $objPHPExcel->getActiveSheet()->setTitle('Hoja1');
    $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
    $objPHPExcel->getDefaultStyle()->getFont()->setSize(8);
    // HOJA 2
    $workSheet2 = new PHPExcel_Worksheet($objPHPExcel, 'Hoja2');
    $objPHPExcel->addSheet($workSheet2, 1);
    $workSheet2->getDefaultStyle()->getFont()->setSize(8);
    $workSheet2->getDefaultStyle()->getFont()->setName('Arial');
    // -----------------------------------------------
    // ENCABEZADOS
    // -----------------------------------------------
    // Se crea el arreglo de hojas. Esto es como llevan el mismo encabezado en todas las hojas, solo es recorrer el index = hojas.
    $objPHPExcel->setActiveSheetIndex(0);
    // Se aplica estilo al encabezado
    $objPHPExcel->getActiveSheet()->getStyle('A7:R7')->applyFromArray($styleEnc);
    // Encabezados
    $headings = array('No', 'Intermodal_Leg_id,', 'Purchase_Order_Number,', 'Global_Name,', 'Transport_Mode,', 'IL_Estimated_Cost,', 'ISC_Customer_Appointment_Date,', 'Booking_Number,', 'Bill_Of_Lading_Number,', 'Vessel_Name,', 'Voyage,', 'POL,', 'POD,', 'Container_Number,', 'Req_Assign_Container,', 'IC_Req_Assign_Container,', 'EQ_Type,', 'Tot_Container_Packages_Weight,', 'LocalLogisticLocation,', 'Cust_Company,', 'DStart_Depot,', 'DEnd_Depot,', 'Booking_Type_Desc,', 'Ex_Short_Description,', 'Shipment_Method,', 'Origin,', 'FDest,', 'I_E,', 'Charge,', 'Result_Std,', 'Seal_No');
    // Escribe los encabezados
    $rowNumber = 7;
    // Freeze pane so that the heading line won't scroll
    $objPHPExcel->getActiveSheet()->freezePane('A8');
    $col = 'A';
    foreach ($headings as $heading) {
        $objPHPExcel->getActiveSheet()->setCellValue($col . $rowNumber, $heading);
        $col++;
    }
    // AutoFiltro
    $objPHPExcel->getActiveSheet()->setAutoFilter('A7:R7');
    // Auto Ajuste de Ancho en Columna
    $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
    $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
    $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
    $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(20);
    $objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('N')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('O')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('P')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('Q')->setWidth(15);
    $objPHPExcel->getActiveSheet()->getColumnDimension('R')->setWidth(15);
    // Titulo
    $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Mediterranean Shipping Company Mexico, S.A. DE C.V.')->getStyle('A1')->applyFromArray($styleTitulo);
    // SUBTitulo
    $objPHPExcel->getActiveSheet()->setCellValue('A2', 'Solo como Agentes / As Agent only');
    $objPHPExcel->getActiveSheet()->getStyle('A2')->applyFromArray($styleSubtitulo);
    $objPHPExcel->getActiveSheet()->setCellValue('A3', '$reportName');
    $objPHPExcel->getActiveSheet()->getStyle('A3')->applyFromArray($styleSubtitulo);
    $objPHPExcel->getActiveSheet()->setCellValue('A6', "{$buque}  {$viaje}");
    $objPHPExcel->getActiveSheet()->getStyle('A6')->applyFromArray($styleSubtitulo);
    // -----------------------------------
    // HOJA 1
    // -----------------------------------
    $objPHPExcel->setActiveSheetIndex(0);
    // Simple query
    $sql = "\n        SELECT\n            PT.Intermodal_Leg_id,\n            PT.Purchase_Order_Number,\n            GC.Global_Name,\n            IC.Transport_Mode,\n            IC.IL_Estimated_Cost,\n            IC.ISC_Customer_Appointment_Date,\n            IC.Booking_Number,\n            IC.Bill_Of_Lading_Number,\n            IC.Vessel_Name,\n            IC.Voyage,\n            IC.POL,\n            IC.POD,\n            IC.Container_Number,\n            IC.Req_Assign_Container,\n            IC.IC_Req_Assign_Container,\n            IC.EQ_Type,\n            IC.Tot_Container_Packages_Weight,\n            IC.LocalLogisticLocation,\n            IC.Cust_Company,\n            IC.DStart_Depot,\n            IC.DEnd_Depot,\n            IC.Booking_Type_Desc,\n            IC.Ex_Short_Description,\n            IC.Shipment_Method,\n            IC.Origin,\n            IC.FDest,\n            IC.I_E,\n            CH.Charge,\n            CH.Result_Std,\n            s.Seal_No\n        FROM\n            Interlink_DFeed90.dfeed.FNTB_Intermodal_Customer (NULL, NULL) IC\n        LEFT JOIN Interlink_Main90.dbo.Assoc_Doc_Company DC (nolock) ON DC.Intermodal_Leg_id = IC.Intermodal_Leg_id\n        LEFT JOIN Interlink_Main90.dbo.GISCompany_Address GA (nolock) ON GA.Company_Address_id = DC.Company_Address_id\n        LEFT JOIN Interlink_Main90.dbo.GISCompany GC (nolock) ON GC.company_id = GA.Company_id\n        LEFT JOIN Interlink_DFeed90.dfeed.FNTB_Intermodal_EDI_Request_Truck (NULL, NULL) PT ON IC.Intermodal_Leg_id = PT.Intermodal_Leg_id\n        LEFT JOIN Interlink_DFeed90.dfeed.FNTB_Charge (1, NULL) CH ON CH.Cargo_Shipment_Container_id = IC.Cargo_Shipment_Container_id\n        AND CH.Charge_DTX_Code = (\n            CASE\n            WHEN CH.I_E = 'E' THEN\n                'PRE'\n            ELSE\n                'ONC'\n            END\n        )\n        LEFT JOIN Interlink_DFeed90.dfeed.FNTB_BOLREP_Container () s ON IC.Container_Number = s.Container_Number\n        AND s.Cargo_Shipment_Container_idx = IC.Cargo_Shipment_Container_id\n        AND s.BC_BOLREP_id = (\n            SELECT\n                MAX (BC_BOLREP_id)\n            FROM\n                Interlink_DFeed90.dfeed.FNTB_BOLREP_Container ()\n            WHERE\n                Container_Number = IC.Container_Number\n            AND Cargo_Shipment_Container_idx = IC.Cargo_Shipment_Container_id\n        )\n        WHERE\n            IC.ISC_Customer_Appointment_Date BETWEEN '{$fec1}' AND '{$fec2}'\n\n    ";
    $rs = odbc_exec($connI, $sql);
    if (!$rs) {
        exit("Error en la consulta SQL");
    }
    $lin = 1;
    $rowNumber = 8;
    // donde inicia los datos
    while (odbc_fetch_row($rs)) {
        $Intermodal_Leg_id = odbc_result($rs, 'Intermodal_Leg_id');
        $Purchase_Order_Number = odbc_result($rs, 'Purchase_Order_Number');
        $Global_Name = odbc_result($rs, 'Global_Name');
        $Transport_Mode = odbc_result($rs, 'Transport_Mode');
        $IL_Estimated_Cost = odbc_result($rs, 'IL_Estimated_Cost');
        $ISC_Customer_Appointment_Date = odbc_result($rs, 'ISC_Customer_Appointment_Date');
        $Booking_Number = odbc_result($rs, 'Booking_Number');
        $Bill_Of_Lading_Number = odbc_result($rs, 'Bill_Of_Lading_Number');
        $Vessel_Name = odbc_result($rs, 'Vessel_Name');
        $Voyage = odbc_result($rs, 'Voyage');
        $POL = odbc_result($rs, 'POL');
//.........这里部分代码省略.........
开发者ID:nesmaster,项目名称:msclink,代码行数:101,代码来源:repHI.php

示例12: PHPExcel

<?php

error_reporting(E_ERROR);
require_once 'includes/cars_pdo.php';
if (isset($_POST['download'])) {
    require_once 'src/PHPExcel.php';
    try {
        $sheet = new PHPExcel();
        // Установить мета свойства
        $sheet->getProperties()->setCreator('www.example.com')->setLastModifiedBy('www.example.com')->setTitle('Used cars for sale')->setKeywords('cars second-hand used');
        // Установить свойства по умолчанию
        $sheet->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
        $sheet->getDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $sheet->getDefaultStyle()->getFont()->setName('Lucida Sans Unicode');
        $sheet->getDefaultStyle()->getFont()->setSize(12);
        // Получить ссылку на активную spreadsheet
        $sheet->setActiveSheetIndex(0);
        $activeSheet = $sheet->getActiveSheet();
        // Установить опции для печати
        $activeSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)->setFitToWidth(1)->setFitToHeight(0);
        $activeSheet->getHeaderFooter()->setOddHeader('&C&B&16' . $sheet->getProperties()->getTitle())->setOddFooter('&CPage &P of &N');
        // Заполнить данными
        $row = getRow($result);
        $colHeaders = array_keys($row);
        $col = 'A';
        $rownum = 1;
        // Установить заголовок столбца
        foreach ($colHeaders as $header) {
            $activeSheet->setCellValue($col . $rownum, $header);
            $activeSheet->getStyle($col . $rownum)->getFont()->setBold(true);
            if ($col == 'G') {
开发者ID:sbogdanov108,项目名称:db_to_text,代码行数:31,代码来源:cars_excel.php

示例13: exportarSifilis

 public function exportarSifilis()
 {
     date_default_timezone_set('America/Lima');
     $nivelUsuario = $this->session->userdata("nivel");
     switch ($nivelUsuario) {
         case '8':
             $where = array("establecimiento" => $nivelUsuario["establecimiento"]);
             $query = $this->db->select("sifilis.*, sifilis_materna.*, sifilis_congenita.*")->from("sifilis")->where($where)->join('sifilis_materna', 'sifilis.codigo=sifilis_materna.codigo', 'left')->join('sifilis_congenita', 'sifilis.codigo=sifilis_congenita.codigo', 'left')->get();
             break;
         case '7':
             $where = array("diresa" => $nivelUsuario["diresa"], "red" => $nivelUsuario["red"], "microred" => $nivelUsuario["microred"]);
             $query = $this->db->select("sifilis.*, sifilis_materna.*, sifilis_congenita.*")->from("sifilis")->where($where)->join('sifilis_materna', 'sifilis.codigo=sifilis_materna.codigo', 'left')->join('sifilis_congenita', 'sifilis.codigo=sifilis_congenita.codigo', 'left')->get();
             break;
         case '6':
             $where = array("diresa" => $nivelUsuario["diresa"], "red" => $nivelUsuario["red"]);
             $query = $this->db->select("sifilis.*, sifilis_materna.*, sifilis_congenita.*")->from("sifilis")->where($where)->join('sifilis_materna', 'sifilis.codigo=sifilis_materna.codigo', 'left')->join('sifilis_congenita', 'sifilis.codigo=sifilis_congenita.codigo', 'left')->get();
             break;
         case '5':
             $where = array("diresa" => $nivelUsuario["diresa"]);
             $query = $this->db->select("sifilis.*, sifilis_materna.*, sifilis_congenita.*")->from("sifilis")->where($where)->join('sifilis_materna', 'sifilis.codigo=sifilis_materna.codigo', 'left')->join('sifilis_congenita', 'sifilis.codigo=sifilis_congenita.codigo', 'left')->get();
             break;
         default:
             $query = $this->db->select("sifilis.*, sifilis_materna.*, sifilis_congenita.*")->from("sifilis")->join('sifilis_materna', 'sifilis.codigo=sifilis_materna.codigo', 'left')->join('sifilis_congenita', 'sifilis.codigo=sifilis_congenita.codigo', 'left')->get();
             break;
     }
     if (!$query) {
         return false;
     }
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getProperties()->setTitle("export")->setDescription("none");
     $objPHPExcel->setActiveSheetIndex(0);
     $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
     $objPHPExcel->getDefaultStyle()->getFont()->setSize(12);
     $fields = $query->list_fields();
     $col = 0;
     foreach ($fields as $field) {
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, 1, $field);
         $col++;
     }
     $row = 2;
     foreach ($query->result() as $data) {
         $col = 0;
         foreach ($fields as $field) {
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $data->{$field});
             $col++;
         }
         $row++;
     }
     $objPHPExcel->setActiveSheetIndex(0);
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="sifilis_' . date('dMy') . '.xls"');
     header('Cache-Control: max-age=0');
     $objWriter->save('php://output');
     redirect(site_url('sifilis/principal'), 301);
 }
开发者ID:alejandrob1519,项目名称:nwsp,代码行数:56,代码来源:modulos2.php

示例14: PHPExcel

 function export_goods_list()
 {
     $cname = $_GET['cname'];
     $list = $_GET['list'];
     $w = '';
     if (!empty($cname) && $cname != 'all') {
         //$cname = str_replace(' ','',trim($cname));
         $w = " WHERE goods_cate LIKE '%{$cname}%'";
     }
     $sql = "SELECT * FROM `{$this->App->prefix()}goods_cache_list` {$w} ORDER BY goods_cate ASC, goods_id DESC LIMIT {$list}";
     $rt = $this->App->find($sql);
     $iconv = Import::gz_iconv();
     require_once SYS_PATH . 'lib/class/PHPExcel.php';
     //require_once SYS_PATH.'lib/class/PHPExcel/IOFactory.php';
     $objPHPExcel = new PHPExcel();
     // 设置基本属性
     $objPHPExcel->getProperties()->setCreator("Sun Star Data Center")->setLastModifiedBy("Sun Star Data Center")->setTitle("Microsoft Office Excel Document")->setSubject("Test Data Report -- From Sunstar Data Center")->setDescription("LD Test Data Report, Generate by Sunstar Data Center")->setKeywords("sunstar ld report")->setCategory("Test result file");
     //print_r($rt); exit;
     // 创建多个工作薄
     $sheet1 = $objPHPExcel->createSheet();
     //$sheet2 = $objPHPExcel->createSheet();
     // 设置第一个工作簿为活动工作簿
     //$objPHPExcel->setActiveSheetIndex(0);
     // 设置活动工作簿名称
     // 如果是中文一定要使用iconv函数转换编码
     $objPHPExcel->getActiveSheet()->setTitle(empty($cname) ? '商品导出' : $cname);
     // 设置默认字体和大小
     $objPHPExcel->getDefaultStyle()->getFont()->setName('宋体');
     $objPHPExcel->getDefaultStyle()->getFont()->setSize(10);
     // 设置一列的宽度
     $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(45);
     $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
     $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(12);
     $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(10);
     $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(12);
     $objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(20);
     $objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(10);
     $objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(10);
     $objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(10);
     $objPHPExcel->getActiveSheet()->getColumnDimension('N')->setWidth(10);
     $objPHPExcel->getActiveSheet()->getColumnDimension('O')->setWidth(10);
     $objPHPExcel->getActiveSheet()->getColumnDimension('P')->setWidth(10);
     $objPHPExcel->getActiveSheet()->getColumnDimension('Q')->setWidth(10);
     $objPHPExcel->getActiveSheet()->getColumnDimension('R')->setWidth(20);
     $objPHPExcel->getActiveSheet()->getColumnDimension('S')->setWidth(20);
     $objPHPExcel->getActiveSheet()->getColumnDimension('T')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('U')->setWidth(15);
     $objPHPExcel->getActiveSheet()->getColumnDimension('V')->setWidth(40);
     $objPHPExcel->getActiveSheet()->getColumnDimension('W')->setWidth(30);
     // 设置行的高度
     // $objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(55);
     // 定义一个样式,加粗,居中
     //$styleArray1 = array( 'font' => array( 'bold' => true, 'color'=>array( 'argb' => '00000000', ), ),  'alignment' => array( 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, ), );
     //$styleArray2 = array( 'font' => array( 'color'=>array( 'argb' => '00000000', ), ),  'alignment' => array( 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, ), );
     //居中
     $objPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('E')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('F')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('G')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('H')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('I')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('J')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('K')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('L')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('M')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('N')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('O')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('P')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('Q')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('R')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('S')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('T')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('U')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('V')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('W')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     //垂直居中
     $objPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('E')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('F')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('G')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('H')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('I')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('J')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('K')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('L')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('M')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('N')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('O')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('P')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle('Q')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
//.........这里部分代码省略.........
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:101,代码来源:controller.php

示例15: generate


//.........这里部分代码省略.........
     $htmltable = str_replace("<br>", "\n", $htmltable);
     $htmltable = str_replace("&nbsp;", " ", $htmltable);
     $htmltable = str_replace("\n\n", "\n", $htmltable);
     //
     //  Extract HTML table contents to array
     //
     $dom = new domDocument();
     $dom->loadHTML($htmltable);
     if (!$dom) {
         echo "<br />Invalid HTML DOM, nothing to Export.";
         exit;
     }
     $dom->preserveWhiteSpace = false;
     // remove redundant whitespace
     $tables = $dom->getElementsByTagName('table');
     if (!is_object($tables)) {
         echo "<br />Invalid HTML Table DOM, nothing to Export.";
         exit;
     }
     if ($debug) {
         fwrite($handle, "\nTable Count: " . $tables->length);
     }
     $tbcnt = $tables->length - 1;
     // count minus 1 for 0 indexed loop over tables
     if ($tbcnt > $limit) {
         $tbcnt = $limit;
     }
     //
     //
     // Create new PHPExcel object with default attributes
     //
     require_once 'PHPExcel/PHPExcel.php';
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
     $objPHPExcel->getDefaultStyle()->getFont()->setSize(9);
     $tm = date(YmdHis);
     $pos = strpos($usermail, "@");
     $user = substr($usermail, 0, $pos);
     $user = str_replace(".", "", $user);
     $tfn = $user . "_" . $tm . "_" . $tablevar . ".xlsx";
     //$fname = "AuditLog/".$tfn;
     $fname = $tfn;
     $objPHPExcel->getProperties()->setCreator($username)->setLastModifiedBy($username)->setTitle("Automated Export")->setSubject("Automated Report Generation")->setDescription("Automated report generation.")->setKeywords("Exported File")->setCompany($usercompany)->setCategory("Export");
     //
     // Loop over tables in DOM to create an array, each table becomes a worksheet
     //
     for ($z = 0; $z <= $tbcnt; $z++) {
         $maxcols = 0;
         $totrows = 0;
         $headrows = array();
         $bodyrows = array();
         $r = 0;
         $h = 0;
         $rows = $tables->item($z)->getElementsByTagName('tr');
         $totrows = $rows->length;
         if ($debug) {
             fwrite($handle, "\nTotal Rows: " . $totrows);
         }
         foreach ($rows as $row) {
             $ths = $row->getElementsByTagName('th');
             if (is_object($ths)) {
                 if ($ths->length > 0) {
                     $headrows[$h]['colcnt'] = $ths->length;
                     if ($ths->length > $maxcols) {
                         $maxcols = $ths->length;
                     }
开发者ID:abdulghanni,项目名称:gsm,代码行数:67,代码来源:export_xls.php


注:本文中的PHPExcel::getDefaultStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。