Export to excel in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rabeehkm
Forum Newbie
Posts: 4
Joined: Fri May 29, 2009 6:34 am

Export to excel in php

Post by rabeehkm »

Hi Experts,

i want to develop a page in which, when i click Export, an excel should open up.

I created a application, and i am able to open a Excel sheet when i click Export.

In the Excel First row contain headings(Name, Address, City)

I want the City to be a dropdown. I have googling for last 2 days, till i didnt find a solution.

The city should be a dropdown, listing cities in the database.

Can any one help me????

Thanks In Advance,
Rabeeh
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Export to excel in php

Post by califdon »

PHP supports exporting a CSV file using a header that indicates that the associated application should be Microsoft Excel, but I don't know of any way to enable any special features of Excel, like dropdown lists. You can do that as HTML, but as far as I know, not in a CSV file, which is basically just a text file.
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: Export to excel in php

Post by mikemike »

You may have more luck with the COM library (this is only available on a Windows server - possibly through Wine, I've never tried). The COM library let's you create Microsoft Office documents dynamically, including (but not exclusively) Excel documents.

As for creating your drop-down boxes I'm not sure, you'll have to read the COM documentation. Creating a CSV would be your easiest option but you're limited to text-only.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Export to excel in php

Post by Mark Baker »

Take a look at a library such as PHPExcel which allows you to create genuine Excel workbooks (rather than simple CSV files) that support the Excel autofilter feature
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Export to excel in php

Post by Benjamin »

:arrow: Moved to PHP - Code
Post Reply