$activeSheet->setCellValue('L5', $count4);
$activeSheet->setCellValue('M5', $count5);
$activeSheet->setCellValue('N5', $count6);
$activeSheet->setCellValue('O5', $count7);
$activeSheet->mergeCells('B9:B' . ($num - 1));
$activeSheet->getStyle('B9:B' . ($num - 1))->applyFromArray($canhgiua);
$activeSheet->getStyle('B9:B' . ($num - 1))->applyFromArray($indam);
$activeSheet->getStyle('C9:C' . (count($arr) + 9))->applyFromArray($canhgiua);
for ($i = 'E'; $i <= 'O'; $i++) {
    $activeSheet->getStyle($i . '9:' . $i . (count($arr) + 9))->applyFromArray($canhgiua);
}
$activeSheet->getStyle('D9:D' . (count($arr) + 9))->applyFromArray($canhtrai);
$activeSheet->getStyle('P9:P' . (count($arr) + 9))->applyFromArray($canhtrai);
$activeSheet->getStyle('Q9:Q' . (count($arr) + 9))->applyFromArray($canhtrai);
$phpColor = new PHPExcel_Style_Color();
$phpColor->setRGB('FF0000');
$activeSheet->setCellValue('D' . ($count + 9 + 6), 'Ghi chú:');
$activeSheet->getStyle('D' . ($count + 9 + 6))->applyFromArray($gachdit);
$activeSheet->getStyle('D' . ($count + 9 + 6))->applyFromArray($innghieng);
$activeSheet->getStyle('D' . ($count + 9 + 6))->applyFromArray($indam);
$activeSheet->getStyle('D' . ($count + 9 + 6))->getFont()->setColor($phpColor);
$objRichText = new PHPExcel_RichText();
$objBold = $objRichText->createTextRun('CÔNG VIỆC:');
$objBold->getFont()->setBold(true);
$objRichText->createText(' Ghi tên công việc mà mình làm thực tế.');
$activeSheet->setCellValue('D' . ($count + 9 + 7), $objRichText);
$activeSheet->mergeCells('D' . ($count + 9 + 7) . ':O' . ($count + 9 + 7));
unset($objBold);
$objRichText = new PHPExcel_RichText();
$objBold = $objRichText->createTextRun('MÃ DỰ ÁN:');
$objBold->getFont()->setBold(true);
Ejemplo n.º 2
0
require_once 'const.php';
require_once 'PHPExcel.php';
$_dir = $_SERVER['DOCUMENT_ROOT'] . TEMP_DIR;
/* 読込 */
/*
$xls = PHPExcel_IOFactory::load($_dir.'/EXCEL_DATA.xlsx');

$xls->setActiveSheetIndex(0);
$sheet = $xls->getActiveSheet();

var_dump($sheet->getCell('B2').$sheet->getCell('C2'));
*/
/* 新規作成 */
$xls = new PHPExcel();
$sheet = $xls->setActiveSheetIndex(0);
$sheet->setCellValue('A1', '氏名', false);
$sheet->setCellValue('A2', '木島 仁', false);
$sheet->setCellValue('B1', '電話番号', false);
$sheet->setCellValue('B2', '03-5298-8868', false);
$sheet->setCellValue('C1', '更新日', false);
$sheet->setCellValue('C2', date('y/m/d'), false);
$sheet->getStyle('A1:C1')->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$color = new PHPExcel_Style_Color();
$color->setRGB('ffcccc');
$color2 = new PHPExcel_Style_Color();
$color2->setRGB('ff6666');
$sheet->getStyle('A1:C1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR);
$sheet->getStyle('A1:C1')->getFill()->setStartColor($color);
$sheet->getStyle('A1:C1')->getFill()->setEndColor($color2);
$writer = PHPExcel_IOFactory::createWriter($xls, 'Excel2007');
$writer->save($_dir . '/WriteSample.xlsx');
Ejemplo n.º 3
0
             }
             $objPHPExcel->getActiveSheet()->setCellValue($cols . ($i + 1), $v);
             if (!empty($row['color']) && $k == $locate->Translate("answered duration")) {
                 $colorcell = $cols . ($i + 1) . ":" . $cols . ($i + 1);
                 $BackgroundColor = new PHPExcel_Style_Color();
                 $BackgroundColor->setRGB($row['color']);
                 $objPHPExcel->getActiveSheet()->getStyle($colorcell)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
                 $objPHPExcel->getActiveSheet()->getStyle($colorcell)->getFill()->setStartColor($BackgroundColor);
             }
         } else {
             //$objPHPExcel->getActiveSheet()->mergeCells(’A18:E22′);合并单元格方法
             //给单元格赋背景色
             if (!empty($row['color']) && $k == $locate->Translate("answered duration")) {
                 $colorcell = $cols . ($i + 1) . ":" . $cols . ($i + 1);
                 $BackgroundColor = new PHPExcel_Style_Color();
                 $BackgroundColor->setRGB($row['color']);
                 $objPHPExcel->getActiveSheet()->getStyle($colorcell)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
                 $objPHPExcel->getActiveSheet()->getStyle($colorcell)->getFill()->setStartColor($BackgroundColor);
             }
             if (is_numeric($v)) {
                 $isnumber[$cols] = 1;
             }
             $objPHPExcel->getActiveSheet()->setCellValue($cols . ($i + 1), $v);
         }
     }
     $i++;
 }
 foreach ($isnumber as $key => $value) {
     $objPHPExcel->getActiveSheet()->getColumnDimension($key)->setAutoSize(true);
 }
 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
Ejemplo n.º 4
0
 public function excelgeneration()
 {
     $this->load->library('excel');
     $this->load->model('reportsmodel');
     $data = array();
     $postdesignation = $postinterest = $postproduct = $postexperience = $postprofessional = $postknowby = array();
     if (!empty($this->input->post('designationselect'))) {
         $postdesignation = $this->input->post('designationselect');
     }
     if (!empty($this->input->post('interestselect'))) {
         $postinterest = $this->input->post('interestselect');
     }
     if (!empty($this->input->post('productselect'))) {
         $postproduct = $this->input->post('productselect');
     }
     if (!empty($this->input->post('experienceselect'))) {
         $postexperience = $this->input->post('experienceselect');
     }
     if (!empty($this->input->post('professionalselect'))) {
         $postprofessional = $this->input->post('professionalselect');
     }
     if (!empty($this->input->post('knowbyselect'))) {
         $postknowby = $this->input->post('knowbyselect');
     }
     $data['fromdate'] = $this->input->post('fromdate');
     $data['todate'] = $this->input->post('todate');
     $excelreport = $this->reportsmodel->fetchFeedbackDetails($data, $postdesignation, $postinterest, $postproduct, $postexperience, $postprofessional, $postknowby);
     // print_r($excelreport);
     // exit;
     //activate worksheet number 1
     $this->excel->setActiveSheetIndex(0);
     //name the worksheet
     $this->excel->getActiveSheet()->setTitle('Feedback Report');
     $this->excel->getActiveSheet()->getStyle('L3:L1000')->getNumberFormat()->setFormatCode('###0');
     $this->excel->getActiveSheet()->getStyle('G3:G1000')->getNumberFormat()->setFormatCode('###0');
     //save it to Excel5 format (excel 2003 .XLS file), change this to 'Excel2007' (and adjust the filename extension, also the header mime type)
     //if you want to save it as .XLSX Excel 2007 format
     $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
     $FontColor = new PHPExcel_Style_Color();
     $FontColor = new PHPExcel_Style_Color();
     $FontColor->setRGB("C5D6F2");
     $m = 'A';
     $p = 1;
     foreach ($excelreport as $exceldata) {
         foreach ($exceldata as $key => $value) {
             if ($p == 2) {
                 $this->excel->setActiveSheetIndex(0)->setCellValue($m . $p, $key);
                 $p = 3;
                 $this->excel->setActiveSheetIndex(0)->setCellValue($m . $p, $value);
                 $p = 2;
             } else {
                 if ($p == 1) {
                     $this->excel->setActiveSheetIndex(0)->setCellValue($m . $p, $key)->getStyle("C1:Z100")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
                 } else {
                     $this->excel->setActiveSheetIndex(0)->setCellValue($m . $p, $value);
                 }
             }
             $m++;
         }
         if ($p == 2) {
             $p = 4;
         } else {
             $p++;
         }
         $m = 'A';
     }
     $sheet = $this->excel->getActiveSheet();
     $lastColumn = $sheet->getHighestColumn();
     $lastColumn++;
     //$sheet->getColumnDimension('A')->setWidth(6);
     $sheet->getStyle('A1:' . $lastColumn . '2')->getFont()->setBold(true);
     for ($i = 'A'; $i != $lastColumn; $i++) {
         $sheet->getColumnDimension($i)->setAutoSize(true);
     }
     $this->excel->setActiveSheetIndex(0)->mergeCells('A1:D1');
     $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
     $chartid = 'Feedback Report';
     header("Content-type: application/vnd.ms-excel");
     header("Content-Disposition: attachment; filename=\"" . $chartid . ".xls\"");
     $objWriter->save('php://output');
 }
Ejemplo n.º 5
0
 $activeSheet->getStyle("A{$count}")->getFont()->setBold(true);
 $activeSheet->getStyle("A{$count}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
 $activeSheet->getStyle("C{$count}")->getFont()->setBold(true)->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING);
 $activeSheet->getStyle("C{$count}")->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED4);
 $activeSheet->setCellValue("E{$count}", "Total");
 $activeSheet->setCellValue("G{$count}", "=SUM(G3:G" . ($count - 1) . ")");
 $activeSheet->getStyle("E{$count}")->getFont()->setBold(true);
 $activeSheet->getStyle("E{$count}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
 $activeSheet->getStyle("G{$count}")->getFont()->setBold(true)->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING);
 $activeSheet->getStyle("G{$count}")->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED4);
 $activeSheet->mergeCells("D2:D{$count}");
 $activeSheet->setCellValue("D2", "Year          " . getIVal("date_format(end_date, '%Y')", "sys_financial_year", "year_id = {$_GET['fyear']}"));
 $activeSheet->getStyle("D2")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER)->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER)->setTextRotation(90);
 $activeSheet->getStyle("D2")->getFont()->setBold(true)->setSize(24);
 $greyColor = new PHPExcel_Style_Color();
 $greyColor->setRGB("D9D9D9");
 $activeSheet->getStyle("A1")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->setStartColor($greyColor);
 $activeSheet->getStyle("D2")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->setStartColor($greyColor);
 $activeSheet->getStyle("A{$count}")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->setStartColor($greyColor);
 $activeSheet->getStyle("B{$count}")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->setStartColor($greyColor);
 $activeSheet->getStyle("C{$count}")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->setStartColor($greyColor);
 $activeSheet->getStyle("E{$count}")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->setStartColor($greyColor);
 $activeSheet->getStyle("F{$count}")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->setStartColor($greyColor);
 $activeSheet->getStyle("G{$count}")->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->setStartColor($greyColor);
 $activeSheet->getStyle("A1:G{$count}")->applyFromArray($tableBorderArray);
 $objPHPExcel->setActiveSheetIndex(0);
 $fileName = "balance_sheet.xlsx";
 header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
 header('Content-Disposition: attachment;filename="' . $fileName . '"');
 header('Cache-Control: max-age=0');
 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
Ejemplo n.º 6
0
 public function reporting()
 {
     $this->load->library("excel");
     $q = isset($_GET['q']) ? $this->input->get('q', TRUE) : '';
     $data_filter = array();
     if (isset($_GET['siteid']) and !empty($_GET['siteid'])) {
         $data_filter['protelindo_site_id'] = $this->input->get('siteid', TRUE);
     }
     if (isset($_GET['region']) and !empty($_GET['region'])) {
         $data_filter['Region'] = $this->input->get('region', TRUE);
     }
     if (isset($_GET['status']) and !empty($_GET['status'])) {
         $data_filter['sla_event_status'] = $this->input->get('status', TRUE);
     }
     if (isset($_GET['desc']) and !empty($_GET['desc'])) {
         $data_filter['tt_status_description'] = $this->input->get('desc', TRUE);
     }
     if (isset($_GET['status_description']) and !empty($_GET['status_description'])) {
         $data_filter['tt_status_description'] = $this->input->get('status_description', TRUE);
     }
     if (isset($_GET['ttno']) and !empty($_GET['ttno'])) {
         $data_filter['tt_no'] = $this->input->get('ttno', TRUE);
     }
     //default tt open
     $data_filter['tt_open'] = $this->input->get('tt_open', TRUE);
     $result = $this->model_tt->reporting($data_filter);
     $this->excel->setActiveSheetIndex(0);
     $fields = $result->list_fields();
     $setting_dimension = array('A' => 30, 'B' => 25, 'C' => 25, 'D' => 25, 'E' => 25, 'F' => 25, 'G' => 25, 'H' => 25, 'I' => 25, 'J' => 25, 'K' => 25, 'L' => 25, 'M' => 25, 'N' => 25, 'O' => 25, 'P' => 25, 'Q' => 25, 'R' => 25, 'S' => 25, 'T' => 25, 'U' => 25, 'V' => 25, 'W' => 25, 'X' => 25, 'Y' => 25, 'Z' => 25, 'AA' => 25, 'AB' => 25, 'AC' => 25, 'AD' => 25, 'AE' => 25, 'AF' => 25, 'AG' => 25, 'AH' => 25);
     foreach ($setting_dimension as $col => $width) {
         $this->excel->getActiveSheet()->getColumnDimension($col)->setWidth($width);
     }
     $this->excel->getActiveSheet()->getStyle('A1:AH1')->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'DA3232')), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER)));
     $phpColor = new PHPExcel_Style_Color();
     $phpColor->setRGB('FFFFFF');
     $this->excel->getActiveSheet()->getStyle('A1:AH1')->getFont()->setColor($phpColor);
     $this->excel->getActiveSheet()->getRowDimension(1)->setRowHeight(40);
     $this->excel->getActiveSheet()->getStyle('A1:AH1')->getAlignment()->setWrapText(true);
     $col = 0;
     foreach ($fields as $field) {
         $this->excel->getActiveSheet()->setCellValueByColumnAndRow($col, 1, $field);
         $col++;
     }
     $row = 2;
     foreach ($result->result() as $data) {
         $col = 0;
         foreach ($fields as $field) {
             if ($col == 19) {
                 $tno = 'TT Number';
                 $tt = $this->model_tt->get_single('tt', 'tt_no', $data->{$tno});
                 $activity = @$this->model_meta->get_meta_single('tt', $tt->idtt, 'tt_description', 'text')->meta_value;
                 $this->excel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $activity);
             } elseif ($col == 32) {
                 $st = 'TT Status';
                 $susName = 'Suspected Trouble Name';
                 $this->excel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, status_tt($data->{$st}, NULL, $data->{$susName}, NULL, FALSE, TRUE));
             } elseif ($col == 9) {
                 $eqtype = 'Equipment Type';
                 if ($data->{$eqtype} == '1') {
                     $type = 'Indoor';
                 } elseif ($data->{$eqtype} == '2') {
                     $type = 'Outdoor';
                 } elseif ($data->{$eqtype} == '3') {
                     $type = 'Base Only';
                 } elseif ($data->{$eqtype} == '4') {
                     $type = 'Outdoor 2';
                 } else {
                     $type = '-';
                 }
                 $this->excel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $type);
             } else {
                 $this->excel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $data->{$field});
             }
             $col++;
         }
         $row++;
     }
     //set border
     $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
     $this->excel->getActiveSheet()->getStyle('A1:AH' . $row)->applyFromArray($styleArray);
     $this->excel->getActiveSheet()->setTitle('TT');
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename=TT-Reporting-' . url_title(user_admin('username')) . '-' . date("Y-M-d") . '.xls');
     header('Cache-Control: max-age=0');
     header('Cache-Control: max-age=1');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Cache-Control: cache, must-revalidate');
     header('Pragma: public');
     $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
     $objWriter->save('php://output');
 }
Ejemplo n.º 7
0
		/**
		 * Generates the sheet's workbook...
		 *
		 * @param String format extension
		 */
		function _generateSheets($format){


			$sheets= array();
			$sheets= $this->book->getSheets();
			$i= 0;


			if ($format=="ods"){

				foreach($sheets as $sheet){

					$cells= array();
					$cells= $sheet->getCells();


					foreach($cells as $cellarray){

						foreach($cellarray as $cell){

						$col= $cell->getDataColumn();
						$row= $cell->getDataRow();
						$data= $cell->getFormula();
						$fontId= $cell->getFontStyleId();
						$fontStyle= new FontStyle();
						$fontStyle= $this->book->getFontStyle($fontId);
						
						

						if (substr($data, 0, 1)== '=')

							$this->objPHPOds->addCell($i,$row,$col,substr($data, 1),'float');
							

						//TODO
						else /*OJO CON ESTO DISCERNIR ENTRE LOS DIFERENTES TIPOS*/

							$this->objPHPOds->addCell($i,$row,$col,$data,'string');

						}
						$this->objPHPOds->addStyle($fontStyle, $cell);
					}
					$i++;
				}
			}
			else{

				foreach($sheets as $sheet){

					if ($i>0)
						$this->objPHPExcel->createSheet();

					$this->objPHPExcel->setActiveSheetIndex($i);
					$j= $i + 1;
					$this->objPHPExcel->getActiveSheet()->setTitle("Sheet $j");

					$cells= array();
					
					$cells= $sheet->getCells();

					foreach($cells as $cellarray){

						$cell= new Cell();
						foreach ($cellarray as $cell){

						
							$col= $cell->getDataColumn();
							$row= $cell->getDataRow();
							$row++;
							
							$data= $cell->getFormula();
//							$this->objPHPExcel= new PHPExcel();
							
							
							$fontId= $cell->getFontStyleId();
							$fontStyle= new FontStyle();
							$fontStyle= $this->book->getFontStyle($fontId);
							$fontName= $fontStyle->getFontName();	
							$fcolor= substr($fontStyle->getFontColor(),1);
							
							if ($fcolor == "000000"){ 
								//echo "$row $col $fcolor<hr>";
							 	$ncolor= new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
							 	$ncolor->setRGB($fcolor);							 	
							}
							else{
								//echo "$row $col $fcolor<hr>";
								$ncolor= new PHPExcel_Style_Color();
								$ncolor->setRGB($fcolor);				
							}	
							
							$style= new PHPExcel_Style();
							$style->getFont()->setColor($ncolor);
							$style->getFont()->setName($fontName);
							$style->getFont()->setBold($fontStyle->getFontBold()== 1);
							$style->getFont()->setItalic($fontStyle->getFontItalic()==1);
							$style->getFont()->setSize($fontStyle->getFontSize());
							
							
							$HzAlign= PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
							
							switch ($fontStyle->fontHAlign){
								
								case 0:									
									$HzAlign= PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
									break;
								case 1:									
									$HzAlign= PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
									break;
								case 2:									
									$HzAlign= PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
									break;
								case 3:									
									$HzAlign= PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
									break;								
							}
				
							$VlAlign= PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
							
							switch ($fontStyle->fontVAlign){
								
								case 0:									
									$VlAlign= PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
									break;
								case 1:									
									$VlAlign= PHPExcel_Style_Alignment::VERTICAL_CENTER;
									break;
								case 2:									
									$VlAlign= PHPExcel_Style_Alignment::VERTICAL_TOP;							
															
							}						
							
							$style->getAlignment()->setHorizontal($HzAlign);
							$style->getAlignment()->setVertical($VlAlign);
							
							
							if ($fontStyle->getFontUnderline()!= 0){
								$style->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
							}
														
							$this->objPHPExcel->getActiveSheet()->duplicateStyle($style, PHPExcel_Cell::stringFromColumnIndex($col) . $row);
							$this->objPHPExcel->getActiveSheet()->getCellByColumnAndRow($col, $row)->setValueExplicit($data, PHPExcel_Cell_DataType::dataTypeForValue($data));							
											
						}
						
					}
						$i++;

					}

				}

		}
Ejemplo n.º 8
0
 public function reporting()
 {
     $this->load->library("excel");
     $q = isset($_GET['q']) ? $_GET['q'] : '';
     $data_filter = array();
     if (isset($_GET['siteid']) and !empty($_GET['siteid'])) {
         $data_filter['pmp_idsite'] = $_GET['siteid'];
     }
     if (isset($_GET['region']) and !empty($_GET['region'])) {
         $data_filter['Region'] = $_GET['region'];
     }
     if (isset($_GET['priority']) and !empty($_GET['priority'])) {
         $data_filter['pmp_priority'] = $_GET['priority'];
     }
     if (isset($_GET['status']) and !empty($_GET['status'])) {
         $data_filter['pmp_status'] = $_GET['status'];
     }
     if (isset($_GET['period']) and !empty($_GET['period'])) {
         $data_filter['pm_period_idpm_period'] = (int) $_GET['period'];
     }
     if (isset($_GET['task_id']) and !empty($_GET['task_id'])) {
         $data_filter['idpm_plan_detil'] = (int) $_GET['task_id'];
     }
     if (isset($_GET['type']) and !empty($_GET['type'])) {
         $type = $_GET['type'];
         $idprotelqc = $this->input->get('idprotelqc');
         if ($type == 'allqc') {
             $data_filter['pmp_qc_protelindo'] = (int) $idprotelqc;
         } elseif ($type == 'qccompletion') {
             $data_filter['pmp_qc_protelindo'] = (int) $idprotelqc;
         } elseif ($type == 'qcwaitingapproval') {
             $data_filter['pmp_qc_protelindo'] = (int) $idprotelqc;
         }
     }
     $result = $this->model_task->reporting($data_filter);
     $this->excel->setActiveSheetIndex(0);
     $fields = $result->list_fields();
     $setting_dimension = array('A' => 40, 'B' => 25, 'C' => 25, 'D' => 25, 'E' => 25, 'F' => 25, 'G' => 25, 'H' => 25, 'I' => 25, 'J' => 25, 'K' => 25, 'L' => 25, 'M' => 25);
     foreach ($setting_dimension as $col => $width) {
         $this->excel->getActiveSheet()->getColumnDimension($col)->setWidth($width);
     }
     //styling
     $this->excel->getActiveSheet()->getStyle('A1:M1')->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'DA3232')), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER)));
     $phpColor = new PHPExcel_Style_Color();
     $phpColor->setRGB('FFFFFF');
     $this->excel->getActiveSheet()->getStyle('A1:M1')->getFont()->setColor($phpColor);
     $this->excel->getActiveSheet()->getRowDimension(1)->setRowHeight(40);
     $this->excel->getActiveSheet()->getStyle('A1:M1')->getAlignment()->setWrapText(true);
     $col = 0;
     foreach ($fields as $field) {
         $this->excel->getActiveSheet()->setCellValueByColumnAndRow($col, 1, $field);
         $col++;
     }
     $row = 2;
     foreach ($result->result() as $data) {
         $col = 0;
         foreach ($fields as $field) {
             $this->excel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $data->{$field});
             $col++;
         }
         $row++;
     }
     //set border
     $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
     $this->excel->getActiveSheet()->getStyle('A1:M' . $row)->applyFromArray($styleArray);
     $this->excel->getActiveSheet()->setTitle('TT');
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename=PM-Reporting-' . url_title(user_admin('username')) . '-' . date("Y-M-d") . '.xls');
     header('Cache-Control: max-age=0');
     header('Cache-Control: max-age=1');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Cache-Control: cache, must-revalidate');
     header('Pragma: public');
     $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
     $objWriter->save('php://output');
 }
Ejemplo n.º 9
-2
 public function setStyle($cellRange, $fontFamily = 'Arial', $fontSize = 10, $colorRGB = '00000000', $bold = false, $italic = false, $underline = false)
 {
     require_once \GO::config()->root_path . 'go/vendor/PHPExcel/PHPExcel/Style.php';
     require_once \GO::config()->root_path . 'go/vendor/PHPExcel/PHPExcel/Style/Font.php';
     require_once \GO::config()->root_path . 'go/vendor/PHPExcel/PHPExcel/Style/Color.php';
     $colorObj = new \PHPExcel_Style_Color();
     $colorObj->setRGB($colorRGB);
     $fontObj = new \PHPExcel_Style_Font();
     $fontObj->setName($fontFamily);
     $fontObj->setSize($fontSize);
     $fontObj->setColor($colorObj);
     $fontObj->setBold($bold);
     $fontObj->setItalic($italic);
     $fontObj->setUnderline($underline);
     $styleObj = new \PHPExcel_Style();
     $styleObj->setFont($fontObj);
     $this->getActiveSheet()->setSharedStyle($styleObj, $cellRange);
 }