CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Excel output downloadable attachment

Print topic Send  topic

Author Message
Ashiff
Posted: 03/01/2004, 12:57 AM

Sir,

I have successfully done downloadable excel sheet for 1 grid with no sorting or any sort.

I need to do the same for 2 grids.

The following code works.

$header_filename = "";
$footer_filename = "";
Header("Content-type: application/vnd.ms-excel");
Header("Pragma: no-cache");
Header("Expires: 0");

but fails as soon as I add

Header("Content-Disposition: attachment; filename=anblo.xls");

I need to force download the page instad of opening the excel sheet in the browser.

Can you help me out.;-)
peterr


Posts: 5971
Posted: 03/01/2004, 1:29 AM

How does it fail? What happens?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Ashiff
Posted: 03/01/2004, 5:26 AM

Hi,

The page name is intl_v.php and the attachment name is anblo.xls

When I click it says intl_v.php, should I save or open. If I do any, it says, the page cannot be found.
DonB
Posted: 03/01/2004, 5:58 AM

Try changing: ContentType = "application/asp-unknown" I use that with
success. Admittedly, the formal definition of the value is related to .ASP
pages but I don't see why that should matter to the browser, even though you
are using PHP on the server.

--
DonB

http://www.gotodon.com/ccbth
Ashiff
Posted: 03/01/2004, 6:37 AM

Hi donB,

I have problem not in content-type but in content disposition.

Otherwise the excel sheet opens in browser but does not get downloaded or open if content-disposition is given.

thanks.
DonB
Posted: 03/01/2004, 6:57 AM

The header elements all work together as a team. Although the error pops up
when you set the disposition, I stand by my original post. It's what I use
to do what you want to do. I think you are seeing Excel reporting a "can't
find file" because you are sending the page with disposition that contains
"attachment". Excel is not seeing the XLS but rather a MIME document that
contains the XLS. You don't want Excel opening it anyway, do you? You were
describing "download" of the spreadsheet. If so, don't send it with
ms-excel as the content type.

--
DonB

http://www.gotodon.com/ccbth


"Ashiff" <Ashiff@forum.codecharge> wrote in message
news:540434ac1eb8a3@news.codecharge.com...
> Hi donB,
>
> I have problem not in content-type but in content disposition.
>
> Otherwise the excel sheet opens in browser but does not get downloaded or
open if content-disposition is given.
>
> thanks.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

peterr


Posts: 5971
Posted: 03/01/2004, 8:33 PM

Ashiff,

See: http://support.microsoft.com/default.aspx?scid=kb;EN-US;303750
Not sure if this applies to you, but I noticed that one of your issues is an incorrect file name intl_v.php instead of anblo.xls.

Actually, there seem to be a lot of problems with Content-Disposition. See:
http://www.google.com/search?q=%22Content-Disposition+a...3Amicrosoft.com

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Ashiff
Posted: 03/07/2004, 8:39 PM

Hi DonB,

That still does not work. any other way!:(
DonB
Posted: 03/08/2004, 5:37 AM

If your browser is Internet Explorer, then perhaps not. You should try
another browser to see if it in fact does work, to determine if the problem
is IE or your code. Microsoft has put a feature in IE where it tries really
hard to figure out what the content is (even if the type is unspecified) so
that it opens with (for example) Excel - even when you don't want it to.

You may be unable to make this do what you want, if you use IE.

--
DonB

http://www.gotodon.com/ccbth


"Ashiff" <Ashiff@forum.codecharge> wrote in message
news:5404bf8eb78888@news.codecharge.com...
> Hi DonB,
>
> That still does not work. any other way!:(
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Robert Rodgers
Posted: 03/08/2004, 9:48 AM

Hello,

I am not sure if it will help

I do this to force download of excel files.

In the Page_AfterInitialize event I do.

Response.Buffer = True

Then before export.

Response.Clear
Response.Contenttype= "application/x-octet-stream"
Response.AddHeader "Content-Disposition", "filename=xlexport.csv"

Export Here.


Response.Flush

Look at : http://www.sylvancomputing.com/ccs/

I have an export class that hooks to grid. And exports the contents of the SQL statement.

rob
Robert Rodgers
Posted: 03/08/2004, 11:28 AM

Oops. I guess that needs to be converted to PHP...
Any one want to take a crack at converting these asp lines to php?

Response.Buffer = True
Response.Clear
Response.Contenttype= "application/x-octet-stream"
Response.AddHeader "Content-Disposition", "filename=xlexport.csv"
> Export Here.
Response.Flush

Thanks
rob
sldnkarm

Posts: 2
Posted: 03/22/2005, 7:36 AM

rob,
I have tried to use your "ExportCVS" as an example on my own search page, without success. I can get the "link" to open up in excel but no data is carried over to the spreadsheet. What is the differences between the button and the hyperlink? Is one better that the other? I just need to be able to export the search results to excel. What you have on your site is exaclty what I need.
Thanks,
Chris
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.