2014-07-09 4 views
6

Die folgenden:PHPExcel bedingte Formatierung, wenn Zellenfolge gleich

$objConditional1 = new PHPExcel_Style_Conditional(); 
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT) 
       ->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT) 
       ->addCondition("Bla bla"); 
$objConditional1->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN); 


$conditionalStyles = $sheet->getStyle('I2')->getConditionalStyles(); 
array_push($conditionalStyles, $objConditional1);    
$sheet->getStyle('I$2:I$10000')->setConditionalStyles($conditionalStyles); 

Generiert ein Excel-Dokument und sagt, dass die bedingte Formatierung Probleme hat und dass sie es entfernen ...

Das richtige Ergebnis i‘ m suchen ist wenn Spalte gleich "Bla bla" füllt das Feld grün

Antwort

9

Die Änderung ist anstelle von addCondition, müssen Sie setText aufrufen ... Was schwer zu schließen ist, aber was auch immer ... cool, ich habe es arbeiten.

$objConditional1 = new PHPExcel_Style_Conditional(); 
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT) 
       ->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT) 
       ->setText("Bla bla"); 
$objConditional1->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN); 


$conditionalStyles = $sheet->getStyle('I2')->getConditionalStyles(); 
array_push($conditionalStyles, $objConditional1);    
$sheet->getStyle('I$2:I$10000')->setConditionalStyles($conditionalStyles); 
+0

Dies markieren auch andere passende Stich jede andere Alternative. Z.B. 1/12 und 11/12 werden beide hervorgehoben – bkac