0

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.

3
Contributors
3
Replies
25
Views
3 Years
Discussion Span
Last Post by iamthwee
0

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.. :(

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.