#2652 bug about show a excel file in IE


the content type is incorrect.it is no need to add the name property.

2764 : // Try to show in browser window
2765 : header ("Content-Disposition: inline; filename=\"$filename\"");
2766 : header ("Content-Type: $type0/$type1; name=\"$filename\"");

the output header
may cause IE show the excel file content directory as a text file.

thank you very much.


  • cowboy

    cowboy - 2009-07-10

    header('Content-Type: application/vnd.ms-excel;name="%E6%96%B0%E8%A6%8FMicrosoft%20Excel%20%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B7%E3%83%BC%E3%83%88.xls"');
    echo "i'am in the excel file.";

    header('Content-Type: application/vnd.ms-excel;name="1.xls"');
    echo "i'am in the excel file.";

    Code1 will show the content in IE.But Code2 will show download dialogue 。

  • Jonathan Angliss

    Maybe I'm a little confused, but your example shows the only difference being in the name="" bit, which is URL encoded in one, and simple in the other, but you're showing a really basic example, SquirrelMail excluded, and getting different behavior from your browser. Or, am I missing something else?

  • cowboy

    cowboy - 2009-07-31

    there is a BUG(?) with IE.(i test only on IE 7 japanese verion.)if there is a NAME property with Content-Type,it may process it incorrectly.
    in fact,it is not necessary to set the NAME property.

    let me show the test code:
    $f="新規Microsoft Excel ワークシート.xls";
    header('Content-Type:application/vnd.ms-excel;name="'.rawurlencode(mb_convert_encoding($f, $_GET['sjis']=='y'?'SJIS':'UTF-8')).'"');
    echo "a raw data in excel format.should not be in IE as text plain";
    when i browse the code,i take the two pics:

    so, please remove the NAME property.

  • Paul Lesniewski

    Paul Lesniewski - 2009-07-31

    I cannot reproduce, although I can't see an excel file in my browser no matter which browser and which way the code is set (probably because I scoff at using MS Office).

    I'm not so convinced about changing the name attribute for this one example because I think it is there for a reason - this code has been developed over 10 years of trial and error.

    That said, apparently there is a problem in this one case. And if the point is to show the file in the browser, is the name attribute necessary? It might be necessary for the rest of the world that does not have the browser extensions to see exel files in their browser, in which case the name attribute might be very helpful for naming the downloaded file.....


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks