Exemple #1
0
 /**
  * @param array $header
  * @param array $rows
  * @return TableElement
  */
 public static function table(array $header = [], array $rows = [])
 {
     $table = new TableElement();
     if (count($header) > 0) {
         $thead = new TableHeadElement();
         $headRow = new TableRowElement();
         $thead->appendContent($headRow);
         foreach ($header as $headerCell) {
             $headRow->appendContent(new TableHeadCellElement(new BoldElement($headerCell)));
         }
         $table->appendContent($thead);
     }
     if (count($rows) > 0) {
         $tbody = new TableBodyElement();
         foreach ($rows as $items) {
             $tableRow = new TableRowElement();
             $tbody->appendContent($tableRow);
             foreach ($items as $item) {
                 $tableRow->cell($item);
             }
         }
         $table->appendContent($tbody);
     }
     return $table;
 }