Dear all,
I have exists excel file on server. Now, I want output the file by php. I have this code:

$file = "test.xls";
$file=basename($file);
if (file_exists($file)) {
    header('Content-Type: application/ms-excel');
    header('Content-Disposition: attachment; filename='.$file);
    ob_clean();
    flush();
    readfile($file);
    exit;
}

When I click download button, I can open file, but appear "missing css file" dialog and content of this file have replaced by special character.
Anyone help me? Thank you in advanced.

Re: Output a excel file by php 80 80

Thanks, the library used to create excel file and then export to client side. But I have already excel file and I want to output it by PHP. My problem is the excel file's content was replaced by CSS file in html.. :(

Re: Output a excel file by php 80 80

So you need to read the cells in the excel and dump tables.

E.g. read excel cell1

table
--row
---excel value
--closerow
close table

etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.