Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting excel throuh php export 1

Status
Not open for further replies.

s0crates9

Technical User
Jun 18, 2005
70
US
I am trying to figure out how to format an excel sheet that has been exported through php.

What I did was get the file to export into excel from mysql, however I want to have the look and design of the excel sheet to be as if I had created the excel file manually. The colors, bolding, font sizes, etc should look like it would in excel...

How do I go about creating this format in a php export? I assume it has something to do with export options or com access, but I really haven't found any info or examples on this.

Thanks!

Web site design, internet marketing, SEO and business solutions company.
 
how did you go about exporting the data? as a csv file?

 
in what format? in native excel format or as comma separated values?

if you are exporting in excel format, what library are you using to generate this format?
 
I am exporting rows from a database in I presume excel native format and not using any library, simply the com access method to spit out an excel download file.

I just wanted to know how I could access options like bolding text or changing background colors without using a php class like biff. I wanted to learn how to do it the hard way!

Thanks!

Web site design, internet marketing, SEO and business solutions company.
 
aha - then you are using a library (the COM).

you can pretty much manipulate excel as you wish through COM (at least in much the same way as you do with VBA).

BUT ... there is an easy way to do all of this. have a look at PEAR::Spreadsheet_Excel_Writer (pear.php.net). this has a pre-built class to help you automate the building of spreadsheets. to make a cell bold it would just be $cell->setBold();

to do similar things natively (without the PEAR class) is much the same ( i haven't tested this - it's from memory):

Code:
$cell->Font->Name = 'Verdana';
$cell->Font->Size = 10;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top