...

View Full Version : Saving data in CSV in PHP



angelali
04-23-2012, 10:20 PM
I have made a function to save data in a CSV file, for this I used the codes on PHP Manual website here:

http://www.php.net/manual/en/function.fputcsv.php

The codes works, except, when I open the file in Excel, I want also a title to appear above the table cell for each column. For example, let's say in the first column of the excel sheet, I am saving some car brands, but can I also make a title automatically via PHP for this column and appear it in bold in Excel? I mean like:

Example:

Cars

BMW
Peugeot
Mercedes

I mean the title Car which is in bold, can I automatically insert it in PHP when processing the CSV? Because now it is only the car brands which are saved...

mlseim
04-24-2012, 01:53 PM
You can't do any formatting with CSV.
CSV is plain text only.

Use XML instead:
http://www.ibm.com/developerworks/opensource/library/os-phpexcel/

Sort of hard to explain, but you can control data (values) as well as cell formatting.

Also some PHP classes for doing Excel stuff ...
http://www.phpclasses.org/package/2037-PHP-Generate-spreadsheet-files-Excel-xls-XML-format.html

Looks sort of advanced to me.
I've never attempted it.



.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum