Merge branch 'ticket-14436-excel-format' into develop
This commit is contained in:
commit
7b9043b4c2
@ -9,6 +9,7 @@ class GenerateWp
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//@ini_set('display_errors', 'on');
|
||||
$this->objPHPExcel = new PHPExcel();
|
||||
$this->columns_es = array(
|
||||
'B' => 'EAN',
|
||||
@ -72,6 +73,9 @@ class GenerateWp
|
||||
'AT' => 'Date de la vente');
|
||||
}
|
||||
|
||||
public static $FORMAT_DARK_BLUE = '214A7B';
|
||||
public static $FORMAT_LIGHT_BLUE = '6C8DCD';
|
||||
public static $FORMAT_LIGHTER_DARK_BLUE = 'C6D9F0';
|
||||
|
||||
public function generate($params)
|
||||
{
|
||||
@ -116,7 +120,7 @@ class GenerateWp
|
||||
$borders_style = array(
|
||||
'borders' => array(
|
||||
'allborders' => array(
|
||||
'style' => PHPExcel_Style_Border::BORDER_THIN
|
||||
'style' => PHPExcel_Style_Border::BORDER_NONE
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -127,21 +131,21 @@ class GenerateWp
|
||||
$this->objPHPExcel->setActiveSheetIndex(0);
|
||||
$activeSheet = $this->objPHPExcel->getActiveSheet();
|
||||
$activeSheet->getRowDimension($i)->setRowHeight(25);
|
||||
if(in_array($key,array('B','C','N','O','P','S','V','W','X','Y'))){
|
||||
if(in_array($key, array('B','C','N','O','P','S','V','W','X','Y'), true)){
|
||||
$activeSheet->getColumnDimension($key)->setWidth(16);
|
||||
} elseif(in_array($key,array('E','F','G','H','I','J','K'))){
|
||||
} elseif(in_array($key, array('E','F','G','H','I','J','K'), true)){
|
||||
$activeSheet->getColumnDimension($key)->setWidth(20);
|
||||
} elseif(in_array($key,array('L','M','Q','R','T'))){
|
||||
} elseif(in_array($key, array('L','M','Q','R','T'), true)){
|
||||
$activeSheet->getColumnDimension($key)->setWidth(10);
|
||||
} elseif(in_array($key,array('Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN'))){
|
||||
} elseif(in_array($key, array('Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN'), true)){
|
||||
$activeSheet->getColumnDimension($key)->setWidth(11);
|
||||
} elseif(in_array($key,array('U','AO'))){
|
||||
} elseif(in_array($key, array('U','AO'), true)){
|
||||
$activeSheet->getColumnDimension($key)->setWidth(45);
|
||||
} elseif(in_array($key,array('AQ','AR','AS','AT'))){
|
||||
} elseif(in_array($key, array('AQ','AR','AS','AT'), true)){
|
||||
$activeSheet->getColumnDimension($key)->setWidth(12);
|
||||
} elseif(in_array($key,array('D'))){
|
||||
} elseif('D' === $key){
|
||||
$activeSheet->getColumnDimension($key)->setWidth(25);
|
||||
} elseif(in_array($key,array('AP'))){
|
||||
} elseif('AP' === $key){
|
||||
$activeSheet->getColumnDimension($key)->setWidth(40);
|
||||
}
|
||||
|
||||
@ -165,28 +169,43 @@ class GenerateWp
|
||||
$activeSheet->getStyle($key.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
|
||||
$activeSheet->getStyle($key.$i)->getAlignment()->setWrapText(true);
|
||||
$activeSheet->getStyle($key.$i)->applyFromArray($borders_style);
|
||||
$activeSheet->getStyle($key.$i)->getFill()->applyFromArray(
|
||||
array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'rotation' => 0,
|
||||
'startcolor' => array(
|
||||
'rgb' => '6C8DCD'
|
||||
),
|
||||
'endcolor' => array(
|
||||
'rgb' => '6C8DCD'
|
||||
)
|
||||
)
|
||||
);
|
||||
if(in_array($key,array('AA','AB','AG','AI','AJ','AL'),true)){
|
||||
$activeSheet->getStyle($key.$i)->getFill()->applyFromArray(
|
||||
array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'rotation' => 0,
|
||||
'startcolor' => array(
|
||||
'rgb' => self::$FORMAT_DARK_BLUE //dark blue
|
||||
),
|
||||
'endcolor' => array(
|
||||
'rgb' => self::$FORMAT_DARK_BLUE //dark blue
|
||||
)
|
||||
)
|
||||
);
|
||||
}else{
|
||||
$activeSheet->getStyle($key.$i)->getFill()->applyFromArray(
|
||||
array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'rotation' => 0,
|
||||
'startcolor' => array(
|
||||
'rgb' => self::$FORMAT_LIGHT_BLUE //light blue
|
||||
),
|
||||
'endcolor' => array(
|
||||
'rgb' => self::$FORMAT_LIGHT_BLUE //light blue
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
foreach ($this->columns_es as $key => $value) {
|
||||
$this->objPHPExcel->setActiveSheetIndex(1);
|
||||
$activeSheet = $this->objPHPExcel->getActiveSheet();
|
||||
$activeSheet->getRowDimension($i)->setRowHeight(25);
|
||||
if(in_array($key,array('B','C','D','F','G','H','J'))) {
|
||||
if(in_array($key, array('B','C','D','F','G','H','J'), true)) {
|
||||
$activeSheet->getColumnDimension($key)->setWidth(13);
|
||||
} elseif(in_array($key,array('E','J'))) {
|
||||
} elseif(in_array($key, array('E','J'), true)) {
|
||||
$activeSheet->getColumnDimension($key)->setWidth(25);
|
||||
} elseif(in_array($key,array('I'))) {
|
||||
} elseif('I' === $key) {
|
||||
$activeSheet->getColumnDimension($key)->setWidth(35);
|
||||
} else {
|
||||
$activeSheet->getColumnDimension($key)->setWidth(8);
|
||||
@ -203,10 +222,10 @@ class GenerateWp
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'rotation' => 0,
|
||||
'startcolor' => array(
|
||||
'rgb' => '6C8DCD'
|
||||
'rgb' => self::$FORMAT_LIGHT_BLUE
|
||||
),
|
||||
'endcolor' => array(
|
||||
'rgb' => '6C8DCD'
|
||||
'rgb' => self::$FORMAT_LIGHT_BLUE
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -408,6 +427,17 @@ class GenerateWp
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$darker_light_blue_style = array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'rotation' => 0,
|
||||
'startcolor' => array(
|
||||
'rgb' => self::$FORMAT_LIGHTER_DARK_BLUE
|
||||
),
|
||||
'endcolor' => array(
|
||||
'rgb' => self::$FORMAT_LIGHTER_DARK_BLUE
|
||||
)
|
||||
);
|
||||
|
||||
$this->objPHPExcel->setActiveSheetIndex(0);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('B5:B'.$lastLine)
|
||||
@ -449,6 +479,53 @@ class GenerateWp
|
||||
->getStyle('AG5:AG'.$lastLine)
|
||||
->getNumberFormat()
|
||||
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AA5:AA' . $lastLine)
|
||||
->getFill()->applyFromArray($darker_light_blue_style);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AB5:AB' . $lastLine)
|
||||
->getFill()->applyFromArray($darker_light_blue_style);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AG5:AG' . $lastLine)
|
||||
->getFill()->applyFromArray($darker_light_blue_style);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AI5:AI' . $lastLine)
|
||||
->getFill()->applyFromArray($darker_light_blue_style);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AJ5:AJ' . $lastLine)
|
||||
->getFill()->applyFromArray($darker_light_blue_style);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AL5:AL' . $lastLine)
|
||||
->getFill()->applyFromArray($darker_light_blue_style);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AA5:AA' . $lastLine)
|
||||
->getFont()->setBold(true);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AB5:AB' . $lastLine)
|
||||
->getFont()->setBold(true);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AG5:AG' . $lastLine)
|
||||
->getFont()->setBold(true);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AI5:AI' . $lastLine)
|
||||
->getFont()->setBold(true);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AJ5:AJ' . $lastLine)
|
||||
->getFont()->setBold(true);
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AL5:AL' . $lastLine)
|
||||
->getFont()->setBold(true);
|
||||
//Conditionnal formating
|
||||
/*$objConditional1 = new PHPExcel_Style_Conditional();
|
||||
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION)
|
||||
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_EQUAL)
|
||||
->addCondition(17);
|
||||
$objConditional1->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
|
||||
|
||||
$conditionalStyles = $this->objPHPExcel->getActiveSheet()->getStyle('T5:T'.$lastLine)->getConditionalStyles();
|
||||
$conditionalStyles[] = $objConditional1;
|
||||
$this->objPHPExcel->getActiveSheet()->getStyle('T5:T'.$lastLine)->setConditionalStyles($conditionalStyles);*/
|
||||
|
||||
$this->objPHPExcel->getActiveSheet()
|
||||
->getStyle('AH5:AH'.$lastLine)
|
||||
->getNumberFormat()
|
||||
|
Loading…
Reference in New Issue
Block a user