0
Well I’m doing the conversion that way:
$html = "
<table width='90%' border='1'>
<tr style='background: #D7D7D7;'>
<th>Título </th>
<th>Título 2</th>
<th>Título 3</th>
</tr>
<tr>
<td>Dados 1</td>
<td>Dados 2</td>
<td>Dados 3</td>
</tr>
<tr>
<td>Dados 4</td>
<td>Dados 5</td>
<td>Dados 6</td>
</tr>
<tr>
<td>Dados 7</td>
<td>Dados 8</td>
<td>Dados 9</td>
</tr>
</table>
";
// Determina que o arquivo é uma planilha do Excel
header("Content-type: application/vnd.ms-excel");
// Força o download do arquivo
header("Content-type: application/force-download");
// Seta o nome do arquivo
header("Content-Disposition: attachment; filename=file.xls");
header("Pragma: no-cache");
// Imprime o conteúdo da nossa tabela no arquivo que será gerado
echo $html;
But I’m facing 2 problems. 1° I need to save the file to the server instead of downloading it, 2° I need to make CSS recognized.
Someone knows how to fix this?
In your example you are creating a xlsx file with Hello World !. it is possible to upload my html to that library?
– Hugo Borges
In fact you will need to assemble cell by cell to your spreadsheet. In the same way you have assembled your HTML... Or your HTML is already ready and you don’t have the data you need?
– fernandosavio
My html is already ready. That’s why I’m trying to convert it.
– Hugo Borges
Then you would have wanted to make one Scrapping from your HTML to extract the data and then assemble the spreadsheet.
– fernandosavio