<?php
require_once('PHPExcel.php');
class PHPExcelCovensol extends PHPExcel {

		public $nroFila=1;
		
		function CeldaTitulo($Columna='A',$textCell='',$autoSize=true,$AnchoCell=0,$Align='left',$Color='',$bold=false){
			
			$textCell=utf8_encode($textCell);
			//str_replace("Â","",utf8_encode("¤"));
									
			if(is_numeric($Columna)){$Columna = PHPExcel_Cell::stringFromColumnIndex($Columna);}
			
			if($Color){$this->ColorLinea($Columna,$Columna,$Color);}						
			
			$this->getActiveSheet()->getStyle($Columna.$this->nroFila)->getFont()->setBold($bold);
			
			if($Align!='number'){
				$this->getActiveSheet()->getStyle($Columna.$this->nroFila)->getAlignment()->setHorizontal($this->Alinear($Align));
			}
			if($Align=='number'){
				$this->getActiveSheet()->getStyle($Columna.$this->nroFila)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
			}
			
			if($autoSize){$this->getActiveSheet()->getColumnDimension($Columna)->setAutoSize(true);}
			else{$this->getActiveSheet()->getColumnDimension($Columna)->setWidth($AnchoCell);}
			$this->setActiveSheetIndex(0)->setCellValue($Columna.$this->nroFila, $textCell);
			//$this->getActiveSheet()->setCellValueByColumnAndRow(1, 8, 'Some value');
		
		}
		
		function CeldaColNumerico($pColumn='1',$textCell='',$autoSize=true,$AnchoCell=0,$Align='left',$Color='',$bold=false){
						
			$Columna = PHPExcel_Cell::stringFromColumnIndex($pColumn);
			
			$textCell=utf8_encode($textCell);
			//str_replace("Â","",utf8_encode("¤"));
			
			if($Color){$this->ColorLinea($Columna,$Columna,$Color);}						
			
			$this->getActiveSheet()->getStyle($Columna.$this->nroFila)->getFont()->setBold($bold);
			
			if($Align!='number'){
				$this->getActiveSheet()->getStyle($Columna.$this->nroFila)->getAlignment()->setHorizontal($this->Alinear($Align));
			}
			if($Align=='number'){
				$this->getActiveSheet()->getStyle($Columna.$this->nroFila)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
			}
			
			if($autoSize){$this->getActiveSheet()->getColumnDimension($Columna)->setAutoSize(true);}
			else{$this->getActiveSheet()->getColumnDimension($Columna)->setWidth($AnchoCell);}
			$this->setActiveSheetIndex(0)->setCellValue($Columna.$this->nroFila, $textCell);
			
		
		}
		
		function Alinear($orient){
				switch($orient){				
					case 'left':
					    $Align = PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
						break;
						
					case 'right':
					    $Align = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
						break;
						
					case 'center':
					    $Align = PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
						break;
				}
		
				return $Align;
		}
		
		function ColorLinea($colStart='A',$colEnd='A',$Color='FFCCCCCC'){
			if(is_numeric($colStart)){$colStart = PHPExcel_Cell::stringFromColumnIndex($colStart);}
			if(is_numeric($colEnd)){$colEnd = PHPExcel_Cell::stringFromColumnIndex($colEnd);}
			
			$this->getActiveSheet()->getStyle($colStart.$this->nroFila)->getFill()->getStartColor()->setARGB($Color);
			$this->getActiveSheet()->getStyle($colStart.$this->nroFila.':'.$colEnd.$this->nroFila)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB($Color);
		
		
		}

}
?>