Csv file and applying styles

hi,
i am creating the csv file and it is working ok but i need to add the styles in the csv file like bold, italic, color etc.

can anybody give me some idea so that i can put the styles in the csv file

thanks
regards

CSV format has no display specific statements or constructs. You must be talking of the styles when displaying the data from a CSV file? Use (x)HTML/CSS; it’s not the data source you want to add styles to, but the displayed data, if that makes sense.

hi, thanks for ur reply php_daemon.
i know that can be done by using html.
when we create an excel file by using the software and we can bold the headings and can apply all the styles which we want to apply.
i am saving the csv file but i also need the formatting; so when the user will download the file and run the file by using the excel software he should be able to see the formatting and other stuff.

hopefully u are getting my point what actually i want to say

thanks
Regards,

As I said, that’s not possible in CSV.

He is, but as he said, the CSV format doesn’t support that kind of styling. Only Excel’s native binary .xls format will support that. If you save a worksheet to csv in Excel you normally get a dialog box warning you of this.

You could try a PHP class that writes in the xls format. I don’t have any links, but I know that one exists. The new XML version of the Excel format is also a possibility, but that isn’t compatible with older versions of office.

Excel also reads HTML. Build a table in HTML and open it in Excel…

There’s also the possibility of writing the file in XML, Excel has this option when saving, so you can study the structure of the document, then build your own. There may be problems for some versions that do not understand Excel written in XML syntax. I use a lot this format at work for both reading and writing until I’ll put up a common back-end solution for all departments.

Write your excel files using http://pear.php.net/package/Spreadsheet_Excel_Writer/ that lets you set wide range of formatting option.