/** * 转换report table到 table * @param ReportTable $reportTable * @return Table */ protected function convertToTable(ReportTable $reportTable) { $output = $this->getMechanic()->getCommand()->getOutput(); $table = new Table($output); $table->setHeaders($reportTable->getHeaders()); $table->setRows($reportTable->getRows()); return $table; }
/** * 转换成html结构 * @param ReportTable $reportTable * @return string */ protected function convertToHtml(ReportTable $reportTable) { $html = '<table border="1" cellpadding="10" cellspacing="10" class="table" style="border:1px solid #ccc;border-collapse:collapse"><tr>'; foreach ($reportTable->getHeaders() as $header) { $html .= "<th>{$header}</th>"; } $html .= "</tr>"; foreach ($reportTable->getRows() as $row) { $html .= "<tr>"; foreach ($row as $cell) { $html .= "<td>{$cell}</td>"; } $html .= "</tr>"; } $html .= "</table>"; return $html; }