Skip to content

Commit

Permalink
piter
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrnov committed Aug 14, 2016
1 parent 9bd5a27 commit 8d299b6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 44 deletions.
6 changes: 5 additions & 1 deletion CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
Change Log: `yii2-postman4excel`
===================================

## Version 2.4.0, no release
## Version 2.4.1,
**Date:** 2016-08-14
1. (bug): containStyle.

## Version 2.4.0,
**Date:** 2016-08-14
1. (bug): headerStyle merge (mergeCells). merge(col,row)
2. (enh): columnAutoSize
Expand Down
88 changes: 45 additions & 43 deletions Postman4ExcelBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
* @var string
* base on scotthuangzl
* @author ptrnov [[email protected]]
* @since 1.0.0
* @since 1.0.0
* @last update 2.4.1
* @state Indonesia
*/
class Postman4ExcelBehavior extends Behavior
Expand Down Expand Up @@ -462,60 +463,61 @@ public function save4Excel($excel_content, $excel_file
//die();
}
for ($row = 0; $row < (count($each_sheet_content['ceils'])+1); $row++) {
if(isset($each_sheet_content['sheet_title'][0])){ // if not have sheet_title
//if(isset($each_sheet_content['sheet_title'][0])){ // if not have sheet_title -- next PR ptr.nov
$content_sheet_titleFirst = count($each_sheet_content['sheet_title']);
$content_sheet_title=$content_sheet_titleFirst==0?$content_sheet_titleFirst:$content_sheet_titleFirst-1;
$cnt_sheet_title_start = count($each_sheet_content['sheet_title']); // count rows of header title
for ($col = 0; $col < count($each_sheet_content['sheet_title'][$content_sheet_title]); $col++) { //Count sub Array sheet_title by [$y]
if (array_key_exists('contentStyle', $each_sheet_content)) {
if (isset($each_sheet_content["contentStyle"][$content_sheet_title][$each_sheet_content['sheet_title'][$content_sheet_title][$col]])) {
$rowStart=$row==0?1:$row;
//Compare Array headerColumnCssClass and Array sheet_title
$tempStyleContent = $each_sheet_content["contentStyle"][$content_sheet_title][$each_sheet_content['sheet_title'][$content_sheet_title][$col]];
$tempColumnContent= self::excelColumnName($col+1) . ($rowStart + $cnt_sheet_title_start); //State range [[0]=>A1,[1]=>B1]
//$tempColumnContent[]= self::excelColumnName($col+1) . ($rowStart + $cnt_sheet_title_start); //State range [[0]=>A1,[1]=>B1]

//align
if (isset($tempStyleContent["align"]) and $tempStyleContent['align']){
$getAliginContent=strtoupper($tempStyleContent["align"]);
if ($getAliginContent=='LEFT'){
$current_sheet->getStyle($tempColumnContent)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
}elseif($getAliginContent=='CENTER'){
$current_sheet->getStyle($tempColumnContent)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
}elseif($getAliginContent=='RIGHT'){
$current_sheet->getStyle($tempColumnContent)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
}else{
$current_sheet->getStyle($tempColumnContent)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
for ($yAB = 0; $yAB < $content_sheet_title; $yAB++) { //Count sub Array sheet_title by [$y]
for ($xAB = 0; $xAB < count($each_sheet_content['sheet_title'][$yAB]); $xAB++) {
for ($colAB = 0; $colAB < count($each_sheet_content['sheet_title'][$xAB]); $colAB++) {
if (array_key_exists('contentStyle', $each_sheet_content)) {
if (isset($each_sheet_content["contentStyle"][$yAB][$each_sheet_content['sheet_title'][$xAB][$colAB]])) {
$rowStart=$row==0?1:$row;
//Compare Array headerColumnCssClass and Array sheet_title
$tempStyleContent = $each_sheet_content["contentStyle"][$yAB][$each_sheet_content['sheet_title'][$xAB][$colAB]];
//$tempStyleContent[] = $each_sheet_content["contentStyle"][$yAB];
//$tempStyleContent[] = [$each_sheet_content['sheet_title'][$xAB][$colAB]];
$tempColumnContent= self::excelColumnName($colAB+1) . ($rowStart + $cnt_sheet_title_start); //State range [[0]=>A1,[1]=>B1]

//align
if (isset($tempStyleContent["align"]) and $tempStyleContent['align']){
$getAliginContent=strtoupper($tempStyleContent["align"]);
if ($getAliginContent=='LEFT'){
$current_sheet->getStyle($tempColumnContent)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
}elseif($getAliginContent=='CENTER'){
$current_sheet->getStyle($tempColumnContent)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
}elseif($getAliginContent=='RIGHT'){
$current_sheet->getStyle($tempColumnContent)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
}else{
$current_sheet->getStyle($tempColumnContent)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
}
}

//font color
if (isset($tempStyleContent["color-font"]) and $tempStyleContent['color-font']){
$current_sheet->getStyle($tempColumnContent)->getFont()->getColor()->setARGB($tempStyleContent['color-font']);
}

//Next Update per cell checking (color-font,color-background)
//color background
if (isset($tempStyleContent["color-background"]) and $tempStyleContent['color-background']) {
$current_sheet->getStyle($tempColumnContent)->getFill()->getStartColor()->setRGB($tempStyle["color-background"]);
$current_sheet->getStyle($tempColumnContent)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
}
}
}

//font color
if (isset($tempStyleContent["color-font"]) and $tempStyleContent['color-font']){
$current_sheet->getStyle($tempColumnContent)->getFont()->getColor()->setARGB($tempStyleContent['color-font']);
}

//Next Update per cell checking (color-font,color-background)
//color background
/* if (isset($tempStyleContent["color-background"]) and $tempStyleContent['color-background']) {
$current_sheet->getStyle($tempColumnContent)->getFill()->getStartColor()->setRGB($tempStyle["color-background"]);
$current_sheet->getStyle($tempColumnContent)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
} */





}
// print_r($tempColumnContent);
// die();
}

}
}
//}
// print_r($tempColumnContent);
// die();
}
}

//$_columnIndex++;
//GRNERAL COLUMN PROPERTY
$lastCnt = count($each_sheet_content['sheet_title']);//count($each_sheet_content['sheet_title']);
$lastCnt_sheet_title=$lastCn==0?$lastCnt:$lastCnt-1;
for ($yA = 0; $yA < $lastCnt_sheet_title ; $yA++){
Expand Down

0 comments on commit 8d299b6

Please sign in to comment.