Does not download the XLS spreadsheet

Asked

Viewed 136 times

2

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

What I need to activate to make it 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;

1 answer

1


Solved!

I had to activate the output_buffering in PHP.INI

Done that, problem solved!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.