NYCPHP Meetup

NYPHP.org

[nycphp-talk] (no subject)

Peter Sawczynec ps at pswebcode.com
Fri Mar 3 13:14:04 EST 2006


This does not exactly solve the specific issue noted here, but this could be
useful for anyone who needs to turn the tabular data output from a database
into an Excel file on the fly. You can do this:

At the very top, first lines of code. No spaces ahead of this because this
is headers:
<?php
header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

//START: GET DATA
//Make your db connection
//Get your data
//END: GET DATA

//START: DATA DISPLAY
//Format you data accurately and consistently with HTML tables, whatever
//END: DATA DISPLAY
?> 

This PHP page will force message box the user's browser 
if they have Excel on their desktop with option to save or open Excel file. 
And the data will be in nice cells and rows that match 
how you had setup your HTML above. 

I have used this successfully.

Peter


-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of jlesidt
Sent: Friday, March 03, 2006 12:01 PM
To: talk at lists.nyphp.org
Subject: [nycphp-talk] (no subject)


Hi,

  I am looking to download rows of data from Mssql database in php. I want
to make an excel file of these rows and zip it so the users can download zip
files. Can someone tell me how to go about with this?

Thanks,




More information about the talk mailing list