I am trying to create another worksheet and everything is working fine. But now I need to create 1 depending on the variable. For instance:
I have two options for checking and one for results. Everything is driven by a boolean called $resultado .
I have a component in CakePHP
function ExcelCargaMasivaComponent() { $this->xls = new PHPExcel(); $this->sheet = $this->xls->getActiveSheet(); $this->sheet->setTitle("Worksheet"); $this->sheet->getDefaultStyle()->getFont()->setName('Verdana'); $this->xls->createSheet(); $this->xls->setActiveSheetIndex(1); $this->validations = $this->xls->getActiveSheet(); $this->validations->setTitle('Validations'); }
If this-> validations is the second worksheet. Now I need this worksheet to have a different name, and therefore I need other data encapsulated in the function. Therefore, my function generates the desired condition as follows:
function ExcelCargaMasivaComponent() { $this->xls = new PHPExcel(); $this->sheet = $this->xls->getActiveSheet(); $this->sheet->setTitle("Worksheet"); $this->sheet->getDefaultStyle()->getFont()->setName('Verdana'); $this->xls->createSheet(); $this->xls->setActiveSheetIndex(1); } function generate($title = 'Report', $headers = array(), $data = array(), $uid = false, $resultados = false){ if($resultados){ $this->validations = $this->xls->getActiveSheet(); $this->validations->setTitle('Resultados'); }else{ $this->validations = $this->xls->getActiveSheet(); $this->validations->setTitle('Validations'); } }
I do this so that the second sheet has a different name and different data depending on the variable, but I could not get it to work. I only generate 1 sheet with a title depending on the variable, this is not what I want.
source share