RE: [PHP] Re: Exporting HTML to Excel

2004-10-13 Thread Gryffyn, Trevor
 Philip Thompson wrote:
 
  -
  ?php
  header('Content-Type: application/ms-excel');
  header('Content-Disposition: attachment; filename=project.xls');
  ?
  
  table
  tr
  tdSomething/td
  /tdSomething else/td
  /tr
  /table
  -
  
  I just want it to have that content in the spreadsheet. 
 
 Works for me... (Excel 2000)
 Something appears in A1
 Something Else appears in B1.

Worked for me too.. Even though I didn't think it would :)  Seemed too
simple.

I'm running Excel 2002.

-TG

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Exporting HTML to Excel

2004-10-13 Thread Philip Thompson
On Oct 13, 2004, at 10:40 AM, Gryffyn, Trevor wrote:
To all who've helped.
Thanks for your input. [embarrassment] Truthfully, when I gave that
example in my original email, I didn't try that specific one. But it
did work for me also when I attempted that one. [/embarrassment]
The reason I was getting a blank spreadsheet was b/c I was
only showing
specific columns based on whether certain $_SESSION variables
were set.
However, the page that's supposed to export to excel, I did
not include
my `session_start()`, so none of the variables were ever TRUE. Once I
saw that and fixed it, it worked like a charm!
But I have run across a small dilemma at this point. I cannot
open the
excel file using IE. However, I can through Mozilla and Safari. Guess
this is something else I have to look at and try to tackle!
Thanks again!
~Philip

table
tr
tdSomething/td
/tdSomething else/td
/tr
/table

Btw: the example above has a /td instead of a td on the second cell
so it puts the values in A1 and A2 instead of A1 and B1.
Yeah, I realized that also whenever all of my items were going in 
column A. But I fixed that.

Another note, I put a td=A1+B1/td and it worked fine (put the
formula in and it evaluates just fine that is).
Neeto feature!
Also, if you're having trouble in IE (I didn't, it worked fine) you
might try changing the MIME type to something that'll download and give
the option of save/open.  There was another thread on this list about
creating folders (not with PHP, but opening a file dialog so the user
could create a folder for the download) that had a lot of good info
about forcing the browser to open that dialog box.
What problem are you having in IE right now?  Is it opening INSIDE IE 
as
an Excel sheet embedded or something (like PDFs do with Acrobat 
Reader)?
I had that happen once or twice while testing the code above.
Well, whenever I click on the link to export to excel (in IE), a File 
Download box pops up. It says the 'File name: toexcel.php' and the 
'File type: ' (blank). It asks if I want to open or save. However, the 
File name should not be toexcel.php (that's the page), it should be 
'project.xls'.

The error message I get whenever I try to Open or Save the file is: IE 
cannot dowload toexcel.php from your.server.com. IE was not able to 
open this Internet site. The requested site is either unavailable or 
cannot be found. Please try again later. This is obviously not true 
b/c I can download from elsewhere.

Here's what I have included in the top of my file (just to reiterate):
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename=project.xls');
I tried adding the `vnd.` to the content-type, thinking that IE might 
like that better, but it didn't. It works just the same though.

Anyway, good luck. Glad you figured out the session problem, that can 
be
frustrating.

-TG
Thanks. Any ideas?
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Exporting HTML to Excel

2004-10-13 Thread John Holmes
Philip Thompson wrote:
Well, whenever I click on the link to export to excel (in IE), a File 
Download box pops up. It says the 'File name: toexcel.php' and the 
'File type: ' (blank). It asks if I want to open or save. However, the 
File name should not be toexcel.php (that's the page), it should be 
'project.xls'.
This is a known issue with IE. I think one workaround is to give the 
filename in the query string as the last variable, i.e.

toexcel.php?f=project.xls
You can just ignore $_GET['f'] in your code, but I think IE will pick 
that up as the filename when you send the download headers.

The error message I get whenever I try to Open or Save the file is: IE 
cannot dowload toexcel.php from your.server.com. IE was not able to open 
this Internet site. The requested site is either unavailable or cannot 
be found. Please try again later. This is obviously not true b/c I can 
download from elsewhere.
Is this over SSL? I've had issues with this also and the solution was to 
change the session.cache_limiter value. It interfered with the download 
for some reason. A search of the archives should bring up some relevant 
threads.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Exporting HTML to Excel

2004-10-13 Thread Philip Thompson
On Oct 13, 2004, at 11:30 AM, John Holmes wrote:
Philip Thompson wrote:
Well, whenever I click on the link to export to excel (in IE), a 
File Download box pops up. It says the 'File name: toexcel.php' and 
the 'File type: ' (blank). It asks if I want to open or save. 
However, the File name should not be toexcel.php (that's the page), 
it should be 'project.xls'.
This is a known issue with IE. I think one workaround is to give the 
filename in the query string as the last variable, i.e.

toexcel.php?f=project.xls
You can just ignore $_GET['f'] in your code, but I think IE will pick 
that up as the filename when you send the download headers.
Tried this, but it doesn't work.

The error message I get whenever I try to Open or Save the file is: 
IE cannot dowload toexcel.php from your.server.com. IE was not able 
to open this Internet site. The requested site is either unavailable 
or cannot be found. Please try again later. This is obviously not 
true b/c I can download from elsewhere.
Is this over SSL? I've had issues with this also and the solution was 
to change the session.cache_limiter value. It interfered with the 
download for some reason. A search of the archives should bring up 
some relevant threads.
Yes, this is on a secure server. I don't have access at this point to 
the .ini file at this point, but I will look into this when my 
supervisor returns tomorrow. Do you happen to know what value to change 
the session.cache_limiter to? I'll search the archives also.

---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
Thanks a bunch.
~Philiip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php