--- dpgirago@xxxxxxxxxxxxxx wrote: > I've used the header function before for redirection with success, > but in > the current situation I'm not sure where to put the 2 calls to it. > I'm > making the web page on the fly -- querying the dB, writing out the > string > including html tags and the query result, using fopen to create the > file, > then using Javascipt to open a browser window displaying the just > created > page. So far I've either gotten the 'can't send headers, output > already > started' error message, or I've gotten the GUI page itself opened > up in > excel, interesting effect but not the intention ;-) > > Does anyone have an idea where to try putting the header calls > given the > above set-up? If you're calling a PHP page from Javascript, then you should put the headers before anything is sent to the browser on that PHP page. For example, <?php header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=excelfile.xls"); ?> <TABLE> <TR><TD>Header 1</TD><TD>Header 2</TD></TR> <TR><TD>R1C1</TD><TD>R1C2</TD></TR> <TR><TD>R2C1</TD><TD>R2C2</TD></TR> </TABLE> The table creation can all be done in PHP as well. If you're building the page using document.write(), things might be more complicated... > Thanks, > > dave > > > Wow, thanks. I'm gonna give this a try right now. > > > dave > > > Mark Weinstock at mark_weinstock@xxxxxxxxx recently wrote... > >> Maybe I'm missing something (quite possible), but you can make > the > >> work happen autogically by using http headers. > > >> header("Content-type: application/octet-stream"); > >> header("Content-Disposition: attachment; > filename=excelfile.xls"); > > >> Replace excelfile.xls with whatever you want the filename to be > > >> Then write out your table as you would normally. the result > should be > >> an excel file either downloaded or opened in the browser, > depending > >> on the browser settings.David ===== Mark Weinstock mark_weinstock@xxxxxxxxx *************************************** You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing. *************************************** __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php