render / display spreadsheet in a browser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sharugan1
Forum Newbie
Posts: 1
Joined: Thu Feb 21, 2008 12:17 pm

render / display spreadsheet in a browser

Post by sharugan1 »

I need to renter and display spreadsheet in browser using php and shouldn't open the pop up window "Save As" asking user to open/save.It should open the xl sheet in the brower with out tool bar of xl .The following code works fine and doesn't show pop up window in IE 7.0.But the same code shows opens the spreadsheet in Microsoft Excel env in IE 6.0 .Please help me fix this issue.I don't want the spredsheet to be opened in the microsoft excel env.it should be opened directly in the browser
what is the problem in the code. works in I.E 7.0 not in I.E 6.0
<?php

$export_file = "test.xls";
//ob_end_clean();
// ini_set('zlib.output_compression','Off');

header('Pragma: public');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: none');
header('Content-Type: application/vnd.ms-excel'); // This should work for IE & Opera
header("Content-type: application/octet-stream");
header('Content-Disposition: inline; filename="'.basename($export_file).'"');
readfile($export_file);

?>
Post Reply