Re: [PHP] Re: Export to Excel

2001-07-14 Thread teo

Hi Marius!
On Fri, 13 Jul 2001, Marius Andreiana wrote:

 How do you deal with numeric fields which start with 0 ?
 Excel takes the 0s out.
 
[wild-guess]

erm, enclose them in `quotes' ?


-- teodor

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Export to Excel

2001-07-13 Thread Philip Hallstrom

Instead of the comma-separated suggestions mentioned in other posts, I'd
recommend using a tab-separated file so that you don't have any confusion
for entries such as addresses that might look like Seattle, WA.  The
other reason is that it's *really* hard to enter a TAB in an HTML form so
it's just nicer.

The other thing to look out for is TEXTAREA inputs where people have
entered newlines.  You'll need to convert those back to spaces before
exporting otherwise the file won't be one record per line.

On Fri, 13 Jul 2001, Jorge Alvarez wrote:

 One of my clients is requesting me to export some data from PHP-generated
 pages to MS Excel files. I have no clue on how to do such export with PHP.
 I'm using PHP/Apache/Linux Mandrake.

 What options do I have?

 Your help is very appreciated.

 Regards,

 Jorge Alvarez
 --
 Let your screen saver contribute to cancer research.
 http://members.ud.com/vypc/cancer/
 A new way to help. Sponsored by Intel.



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Export to Excel

2001-07-13 Thread Marius Andreiana

How do you deal with numeric fields which start with 0 ?
Excel takes the 0s out.

Thanks,
Marius Andreiana
--
You don't have to go to jail for helping your neighbour
http://www.gnu.org/philosophy/


 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Export to Excel

2001-07-13 Thread Tim Frank

Jorge,

I pieced together a way to do this from other suggestions I found on the 
mailing list and elsewhere. This is more of a trick to get Excel to think 
it has an Excel file, but it doesn't truly generate an Excel file.
Thanks to Excel versions 97 and up (don't recall 95) having nice little 
HTML import abilities we can trick it into loading a plain old HTML table 
and treating it as an Excel file.  Here is how you do it.

The following headers will let you throw the file for download so the 
client can save it to their computer.  Just name it with .xls and then 
when they try to open it Excel will automatically convert it from HTML.  
You can change this to inline if you want IE to display it in the 
browser.

header(Content-Type: application/vnd.ms-excel; name='excel');
header(Content-Disposition: attachment; filename=filename.xls);

Now, as far as the data goes, it's simple, just make your run of the mill 
HTML table.  The usual for loop for database records will do, and you 
will just end up with something like this

table
tr
tdColumn with Text/td
tdColumn with Numbers/td
tdColumn with Numbers/Text with leading zeros/td
/tr
tr
tdI am text/td
td1,500.00/td
td=0012/td
/tr
/table

When Excel loads that it will make a 3 column sheet and fill in the data. 
 Any cells you want to keep with leading zerios you use =0012 in the 
HTML table as the data.  Otherwise the column will be treated as numeric 
when it is loaded.  Text stays as text.

There are some tricks as well where you can store forumlas in the actual 
HTML table cells so when the sheet is loaded it would calculate the sum, 
avg, whatever of the columns or sheet.  I don't recall how to do that off 
the top of my head but I think you just plugged in regular formulae into 
the HTML table cells. Try it if you need it.

From there the user might have to set some data types for some columns as 
I don't think they can be set. You might want to check some of the help 
on MS Excel 2K or XP as I'm very sure the HTML capabilities are much more 
advanced than with 97 which we still use.

I hope that helps everyone out a little.  There are limitations with this 
method, but to just get a file that someone can safely open in Excel, it 
is a very convenient way to do it rather than having to muck around with 
binary files.

Have a good weekend,

Tim Frank


 Original Message 

On 7/13/01, 12:58:18 PM, [EMAIL PROTECTED] (Jorge Alvarez) wrote 
regarding Export to Excel:


 One of my clients is requesting me to export some data from PHP-generated
 pages to MS Excel files. I have no clue on how to do such export with 
PHP.
 I'm using PHP/Apache/Linux Mandrake.

 What options do I have?

 Your help is very appreciated.

 Regards,

 Jorge Alvarez
 --
 Let your screen saver contribute to cancer research.
 http://members.ud.com/vypc/cancer/
 A new way to help. Sponsored by Intel.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]