Does not download the XLS worksheet

2

The system was in a reseller and I had to migrate to a VPS with Cpanel, the script to generate the XLS was working fine, opened and downloaded, but now it just opens on the screen

What do I need to enable to work properly?

$html = '<table>
    <tr>
        <td>Coluna 1</td>        
        <td>Coluna 2</td>        
        <td>Coluna 2</td>        
    </tr>
    <tr>
        <td>Coluna 1</td>        
        <td>Coluna 2</td>        
        <td>Coluna 2</td>        
    </tr>
    <tr>
        <td>Coluna 1</td>        
        <td>Coluna 2</td>        
        <td>Coluna 2</td>        
    </tr>
</table>';

// Configurações header para forçar o download
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-type: application/x-msexcel");
header ("Content-Disposition: attachment; filename=\"nome_arquivo.xls\"" );
header ("Content-Description: PHP Generated Data" );

echo $html;
asked by anonymous 18.09.2017 / 18:20

1 answer

1

Solved!

You had to enable output_buffering in PHP.INI

Done that, problem solved!

    
19.09.2017 / 15:16