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


PHP PHPExcel_Style_Conditional::getStyle方法代码示例

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


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

示例1: _writeCFRule

 /**
  * Write CFRule Record
  * @param PHPExcel_Style_Conditional $conditional
  */
 private function _writeCFRule(PHPExcel_Style_Conditional $conditional)
 {
     $record = 0x1b1;
     // Record identifier
     // $type : Type of the CF
     // $operatorType : Comparison operator
     if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) {
         $type = 0x2;
         $operatorType = 0x0;
     } else {
         if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS) {
             $type = 0x1;
             switch ($conditional->getOperatorType()) {
                 case PHPExcel_Style_Conditional::OPERATOR_NONE:
                     $operatorType = 0x0;
                     break;
                 case PHPExcel_Style_Conditional::OPERATOR_EQUAL:
                     $operatorType = 0x3;
                     break;
                 case PHPExcel_Style_Conditional::OPERATOR_GREATERTHAN:
                     $operatorType = 0x5;
                     break;
                 case PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL:
                     $operatorType = 0x7;
                     break;
                 case PHPExcel_Style_Conditional::OPERATOR_LESSTHAN:
                     $operatorType = 0x6;
                     break;
                 case PHPExcel_Style_Conditional::OPERATOR_LESSTHANOREQUAL:
                     $operatorType = 0x8;
                     break;
                 case PHPExcel_Style_Conditional::OPERATOR_NOTEQUAL:
                     $operatorType = 0x4;
                     break;
                 case PHPExcel_Style_Conditional::OPERATOR_BETWEEN:
                     $operatorType = 0x1;
                     break;
                     // not OPERATOR_NOTBETWEEN 0x02
             }
         }
     }
     // $szValue1 : size of the formula data for first value or formula
     // $szValue2 : size of the formula data for second value or formula
     $arrConditions = $conditional->getConditions();
     $numConditions = sizeof($arrConditions);
     if ($numConditions == 1) {
         $szValue1 = $arrConditions[0] <= 65535 ? 3 : 0x0;
         $szValue2 = 0x0;
         $operand1 = pack('Cv', 0x1e, $arrConditions[0]);
         $operand2 = null;
     } else {
         if ($numConditions == 2 && $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BETWEEN) {
             $szValue1 = $arrConditions[0] <= 65535 ? 3 : 0x0;
             $szValue2 = $arrConditions[1] <= 65535 ? 3 : 0x0;
             $operand1 = pack('Cv', 0x1e, $arrConditions[0]);
             $operand2 = pack('Cv', 0x1e, $arrConditions[1]);
         } else {
             $szValue1 = 0x0;
             $szValue2 = 0x0;
             $operand1 = null;
             $operand2 = null;
         }
     }
     // $flags : Option flags
     // Alignment
     $bAlignHz = $conditional->getStyle()->getAlignment()->getHorizontal() == null ? 1 : 0;
     $bAlignVt = $conditional->getStyle()->getAlignment()->getVertical() == null ? 1 : 0;
     $bAlignWrapTx = $conditional->getStyle()->getAlignment()->getWrapText() == false ? 1 : 0;
     $bTxRotation = $conditional->getStyle()->getAlignment()->getTextRotation() == null ? 1 : 0;
     $bIndent = $conditional->getStyle()->getAlignment()->getIndent() == 0 ? 1 : 0;
     $bShrinkToFit = $conditional->getStyle()->getAlignment()->getShrinkToFit() == false ? 1 : 0;
     if ($bAlignHz == 0 || $bAlignVt == 0 || $bAlignWrapTx == 0 || $bTxRotation == 0 || $bIndent == 0 || $bShrinkToFit == 0) {
         $bFormatAlign = 1;
     } else {
         $bFormatAlign = 0;
     }
     // Protection
     $bProtLocked = $conditional->getStyle()->getProtection()->getLocked() == null ? 1 : 0;
     $bProtHidden = $conditional->getStyle()->getProtection()->getHidden() == null ? 1 : 0;
     if ($bProtLocked == 0 || $bProtHidden == 0) {
         $bFormatProt = 1;
     } else {
         $bFormatProt = 0;
     }
     // Border
     $bBorderLeft = $conditional->getStyle()->getBorders()->getLeft()->getColor()->getARGB() == PHPExcel_Style_Color::COLOR_BLACK && $conditional->getStyle()->getBorders()->getLeft()->getBorderStyle() == PHPExcel_Style_Border::BORDER_NONE ? 1 : 0;
     $bBorderRight = $conditional->getStyle()->getBorders()->getRight()->getColor()->getARGB() == PHPExcel_Style_Color::COLOR_BLACK && $conditional->getStyle()->getBorders()->getRight()->getBorderStyle() == PHPExcel_Style_Border::BORDER_NONE ? 1 : 0;
     $bBorderTop = $conditional->getStyle()->getBorders()->getTop()->getColor()->getARGB() == PHPExcel_Style_Color::COLOR_BLACK && $conditional->getStyle()->getBorders()->getTop()->getBorderStyle() == PHPExcel_Style_Border::BORDER_NONE ? 1 : 0;
     $bBorderBottom = $conditional->getStyle()->getBorders()->getBottom()->getColor()->getARGB() == PHPExcel_Style_Color::COLOR_BLACK && $conditional->getStyle()->getBorders()->getBottom()->getBorderStyle() == PHPExcel_Style_Border::BORDER_NONE ? 1 : 0;
     if ($bBorderLeft == 0 || $bBorderRight == 0 || $bBorderTop == 0 || $bBorderBottom == 0) {
         $bFormatBorder = 1;
     } else {
         $bFormatBorder = 0;
     }
     // Pattern
     $bFillStyle = $conditional->getStyle()->getFill()->getFillType() == null ? 0 : 1;
//.........这里部分代码省略.........
开发者ID:ljhchshm,项目名称:weixin,代码行数:101,代码来源:Worksheet.php

示例2: date

// 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");
// Create a first sheet, representing sales data
echo date('H:i:s'), " Add some data", EOL;
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', '-0.5')->setCellValue('A2', '-0.25')->setCellValue('A3', '0.0')->setCellValue('A4', '0.25')->setCellValue('A5', '0.5')->setCellValue('A6', '0.75')->setCellValue('A7', '1.0')->setCellValue('A8', '1.25');
$objPHPExcel->getActiveSheet()->getStyle('A1:A8')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
// Add conditional formatting
echo date('H:i:s'), " Add conditional formatting", EOL;
$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS)->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN)->addCondition('0');
$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
$objConditional3 = new PHPExcel_Style_Conditional();
$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS)->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL)->addCondition('1');
$objConditional3->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
$conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle('A1')->getConditionalStyles();
array_push($conditionalStyles, $objConditional1);
array_push($conditionalStyles, $objConditional3);
$objPHPExcel->getActiveSheet()->getStyle('A1')->setConditionalStyles($conditionalStyles);
//	duplicate the conditional styles across a range of cells
echo date('H:i:s'), " Duplicate the conditional formatting across a range of cells", EOL;
$objPHPExcel->getActiveSheet()->duplicateConditionalStyle($objPHPExcel->getActiveSheet()->getStyle('A1')->getConditionalStyles(), 'A2:A8');
// 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;
开发者ID:padmanabhan-developer,项目名称:Norway-GO,代码行数:31,代码来源:08conditionalformatting2.php

示例3:

$objDrawing->setOffsetX(110);
$objDrawing->setRotation(25);
$objDrawing->getShadow()->setVisible(true);
$objDrawing->getShadow()->setDirection(45);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
//Play around with inserting and removing rows and columns
$objPHPExcel->getActiveSheet()->insertNewRowBefore(6, 10);
$objPHPExcel->getActiveSheet()->removeRow(6, 10);
$objPHPExcel->getActiveSheet()->insertNewColumnBefore('E', 5);
$objPHPExcel->getActiveSheet()->removeColumn('E', 5);
//Add conditional formatting
$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
$objConditional1->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN);
$objConditional1->setCondition('0');
$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
$objConditional1->getStyle()->getFont()->setBold(true);
//Set autofilter 自动过滤
$objPHPExcel->getActiveSheet()->setAutoFilter('A1:C9');
//Hide "Phone" and "fax" column 隐藏列
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
//Set document security 设置文档安全
$objPHPExcel->getSecurity()->setLockWindows(true);
$objPHPExcel->getSecurity()->setLockStructure(true);
$objPHPExcel->getSecurity()->setWorkbookPassword("PHPExcel");
//Set sheet security 设置工作表安全
$objPHPExcel->getActiveSheet()->getProtection()->setPassword('PHPExcel');
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
// This should be enabled in order to enable any of the following!
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
开发者ID:liuxi12138,项目名称:qiandao_php,代码行数:31,代码来源:phpexcel.php

示例4: date

$objConditional1->addCondition('400');
$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_YELLOW);
$objConditional1->getStyle()->getFont()->setBold(true);
$objConditional1->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
$objConditional2 = new PHPExcel_Style_Conditional();
$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
$objConditional2->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN);
$objConditional2->addCondition('0');
$objConditional2->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
$objConditional2->getStyle()->getFont()->setBold(true);
$objConditional2->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
$objConditional3 = new PHPExcel_Style_Conditional();
$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
$objConditional3->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL);
$objConditional3->addCondition('0');
$objConditional3->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
$objConditional3->getStyle()->getFont()->setBold(true);
$objConditional3->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
$conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles();
array_push($conditionalStyles, $objConditional1);
array_push($conditionalStyles, $objConditional2);
array_push($conditionalStyles, $objConditional3);
$objPHPExcel->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
$objPHPExcel->getActiveSheet()->duplicateStyle($objPHPExcel->getActiveSheet()->getStyle('B2'), 'B3:B7');
// Set fonts
echo date('H:i:s') . " Set fonts\n";
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('A7')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('B7')->getFont()->setBold(true);
// Set header and footer. When no different headers for odd/even are used, odd header is assumed.
开发者ID:xmasclaux,项目名称:OpenGenepi,代码行数:31,代码来源:08conditionalformatting.php

示例5: setBold

 public static function setBold(&$objPHPExcel, $countCol, $startCol = 'A', $startRow = 1)
 {
     $objConditional1 = new \PHPExcel_Style_Conditional();
     $objConditional1->setConditionType(\PHPExcel_Style_Conditional::CONDITION_CELLIS);
     $objConditional1->setOperatorType(\PHPExcel_Style_Conditional::OPERATOR_LESSTHAN);
     $objConditional1->addCondition('0');
     $objConditional1->getStyle()->getFont()->getColor()->setARGB(\PHPExcel_Style_Color::COLOR_BLACK);
     $objConditional1->getStyle()->getFont()->setBold(true);
     $objConditional2 = new \PHPExcel_Style_Conditional();
     $objConditional2->setConditionType(\PHPExcel_Style_Conditional::CONDITION_CELLIS);
     $objConditional2->setOperatorType(\PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL);
     $objConditional2->addCondition('0');
     $objConditional2->getStyle()->getFont()->getColor()->setARGB(\PHPExcel_Style_Color::COLOR_BLACK);
     $objConditional2->getStyle()->getFont()->setBold(true);
     $conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle('A1')->getConditionalStyles();
     array_push($conditionalStyles, $objConditional1);
     array_push($conditionalStyles, $objConditional2);
     $letter = $startCol;
     for ($j = 0; $j < $countCol; $j++) {
         $cell = $letter . $startRow;
         $objPHPExcel->getActiveSheet()->getStyle($cell)->setConditionalStyles($conditionalStyles);
         $letter++;
     }
 }
开发者ID:khavq,项目名称:smdemo,代码行数:24,代码来源:ExcelUtility.php


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