Amigos,
Crie uma função básica para exportar para excel uma determinada tabela, até aí perfeito. Porém gostaria de incluir uma coluna com a imagem ao lado. Mais não consegui. Vejam com fiz:
public function actionImpressao() {
$total = 1;
$tamanhofonte = "12";
$sql = "SELECT n.nome AS Defeito, n.descricao AS Descricao, n.causas AS Causas, CONCAT(s.nome,' - ', s.unidade) AS Setor,
(SELECT ncimg.path FROM naoconformidadesimages ncimg WHERE ncimg.naoconformidades = n.idnaoconformidades LIMIT 0,1) As Image
FROM naoconformidades n
JOIN setores s ON s.idsetores = n.setor
ORDER BY Setor, Defeito ASC";
$query = Yii::app()->db->createCommand($sql)->queryAll();
$html = '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="pt-br, pt">
<title>SGI</title>';
$html .= '<table align="center" border="0" cellpadding="0" cellspacing="0" width="800">
<tr>
<td colspan="6" style="text-align: center; font-size:15">
</td>
</tr>
<tr>
<td colspan="6" style="text-align: center; font-size:11">
<samp><b>Catálogo de Não Conformidades</b></samp>
</td>
</tr>
</table>';
$html .= '<table align="center" border rules="all" bordercolor="#E6E6FA" cellpadding="0" cellspacing="0" width="800">
<tr style="height: 15pt;" height="20">
<td valign="top" bgcolor="#E6E6FA" style="text-align: center; font-size:' . $tamanhofonte . '"><samp><b>Seq</b></samp></td>
<td valign="top" bgcolor="#E6E6FA" style="font-size:' . $tamanhofonte . '"><samp><b>Não Conformidade</b></samp></td>
<td valign="top" bgcolor="#E6E6FA" style="font-size:' . $tamanhofonte . '"><samp><b>Descrição</b></samp></td>
<td valign="top" bgcolor="#E6E6FA" style="text-align: center; font-size:' . $tamanhofonte . '"><samp><b>Causas</b></samp></td>
<td valign="top" bgcolor="#E6E6FA" style="text-align: center; font-size:' . $tamanhofonte . '"><samp><b>Setor</b></samp></td>
<td valign="top" bgcolor="#E6E6FA" style="text-align: center; font-size:' . $tamanhofonte . '"><samp><b>Possui Fotos</b></samp></td>
</tr>';
foreach ($query as $row) {
$html.='<tr>
<td valign="top" align=center style="font-size:' . $tamanhofonte . '"><samp>' . $total++ . '</samp></td>
<td valign="top" style="font-size:' . $tamanhofonte . '"><samp>' . $row['Defeito'] . '</samp></td>
<td valign="top" style="font-size:' . $tamanhofonte . '"><samp>' . $row['Descricao'] . '</samp></td>
<td valign="top" style="font-size:' . $tamanhofonte . '"><samp>' . $row['Causas'] . '</samp></td>
<td valign="top" style="font-size:' . $tamanhofonte . '"><samp>' . $row['Setor'] . '</samp></td>
<td valign="top" style="font-size:' . $tamanhofonte . '"><samp><img src="' . Yii::app()->baseUrl . '' . $row['Image'] . '" width="125" height="140" align="left"/></samp></td>
</tr>';
}
$html .= '</table>
</head>
</html>';
Yii::app()->request->sendFile('Catálogo de Não Conformidades.xls', $html);
}
A tabela vai perfeito, porém a coluna das Imagens não aparece nada. Apena um erro dizendo que não foi possível visualizar o arquivo. O que fiz de errado?