Example #1
0
 protected function _signupSheet($event, $includeEndingTerms, $includeNotEndingTerms)
 {
     $sheet = new PHPExcel_Worksheet($this->_excelDoc, 'Signup Sheet for Workshop ' . $event['workshopTitle']);
     // Set up the margins so the header doesn't bleed into the page
     $sheet->getPageMargins()->setTop(1.5);
     // Make a three column page layout
     $sheet->getColumnDimension('A')->setWidth(16);
     $sheet->getColumnDimension('B')->setWidth(16);
     $sheet->getColumnDimension('C')->setWidth(45);
     $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/config.xml', 'production');
     $date = new DateTime($event['date']);
     $startTime = new DateTime($event['startTime']);
     $endTime = new DateTime($event['endTime']);
     // Set the header on odd pages.
     // The code formatting is off because the header doesn't ignore spaces.
     /*
      * Format:
      *        Title
      *        Room name
      *        date('D, M d, Y') (startTime('g:i A') - endTime('g:i A'))
      *        Instructors  
      * 
      */
     $sheet->getHeaderFooter()->setOddHeader('&C&B&14' . $event['workshopTitle'] . '&14&B&12 ' . chr(10) . $event['location'] . chr(10) . $date->format('l, M d, Y') . '(' . $startTime->format('g:i A') . ' - ' . $endTime->format('g:i A') . ')' . chr(10) . 'Instructor: ' . implode(',', $event['instructors']) . '&12&C');
     // Write Column Headers for the table
     $sheet->setCellValue('A1', 'First Name');
     $sheet->setCellValue('B1', 'Last Name');
     $sheet->setCellValue('C1', 'Signature');
     // reformat it a little bit in a simpler way for us to use it in our
     // spreadsheet printin' loop
     $rows = array();
     foreach ($event['attendeeList'] as $a) {
         $rows[] = array($a['firstName'], $a['lastName']);
     }
     $signin = new PHPExcel_Style();
     $signin->applyFromArray(array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN))));
     $rowCounter = 3;
     foreach ($rows as $row) {
         $row = array_values($row);
         // put the totals in the row
         $char = self::A;
         foreach ($row as $cell) {
             $sheet->setCellValue(chr($char) . $rowCounter, $cell);
             $char++;
         }
         $rowCounter++;
     }
     $tableHeaderStyle = new PHPExcel_Style();
     $tableHeaderStyle->applyFromArray($this->_tableHeaderStyleArray);
     $tableBodyStyle = new PHPExcel_Style();
     $tableBodyStyle->applyFromArray($this->_contentStyleArray);
     $sheet->setSharedStyle($tableHeaderStyle, 'A1:C1');
     $sheet->setSharedStyle($tableBodyStyle, 'A3:B' . ($rowCounter - 1));
     $sheet->setSharedStyle($signin, 'C3:C' . ($rowCounter - 1));
     return $sheet;
 }
Example #2
0
 /**
  *
  * @param DOMElement $table
  * @return boolean 
  */
 protected function _addTableFooter($table)
 {
     $tfoot = $table->getElementsByTagName('tfoot');
     if (empty($tfoot->length)) {
         return false;
     }
     $tfoot = $tfoot->item(0);
     $rows = $tfoot->getElementsByTagName('tr');
     $rowStarted = $this->_currentRow;
     foreach ($rows as $row) {
         $this->_currentCell = $this->_startCol;
         $cells = $row->getElementsByTagName('th');
         // Insert each row cell
         foreach ($cells as $cell) {
             $this->_addCell($cell);
         }
         $this->_currentRow++;
     }
     $range = array(PHPExcel_Cell::stringFromColumnIndex($this->_startCol) . $rowStarted, PHPExcel_Cell::stringFromColumnIndex($this->_currentCell - 1) . ($this->_currentRow - 1));
     $range = implode(':', $range);
     $this->_mainSheet->setSharedStyle($this->_styles['table_footer'], $range);
 }
Example #3
0
 /**
  * Inserts data into worksheet and returns it
  * 
  * @return PHPExcel_Worksheet
  */
 public function render()
 {
     // Set worksheet header
     $this->_set_row(1, $this->columns, TRUE);
     //set header style
     $obj_style = new PHPExcel_Style();
     $style = Kohana::$config->load('phpexcel.header');
     $obj_style->applyFromArray($style);
     $column_dim = PHPExcel_Cell::stringFromColumnIndex(count($this->columns) - 1);
     $this->_worksheet->setSharedStyle($obj_style, 'A1:' . $column_dim . '1');
     // Set data
     $rows = 0;
     foreach ($this->data as $row => $data) {
         $this->_set_row($row + 2, $data);
         $rows++;
     }
     // Set column styles and width
     $column = 0;
     foreach (array_keys($this->columns) as $key) {
         $column_dim = PHPExcel_Cell::stringFromColumnIndex($column);
         $format = Arr::get($this->formats, $key);
         if ($format !== NULL) {
             $this->_worksheet->getStyle($column_dim . 2 . ':' . $column_dim . (2 + $rows))->getNumberFormat()->setFormatCode($format);
         }
         if ($this->auto_size === TRUE) {
             $this->_worksheet->getColumnDimension($column_dim)->setAutoSize(TRUE);
         }
         $column++;
     }
     return $this->_worksheet;
 }