Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

Font styling in a csv file

Is there any way to create a csv file & somehow identify cell formatting (font sizes, colors, etc.)?

I'm writing the csv file in php on a web server, to be downloaded to Excel.

I will not be surprised if the answer is no.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of TelnetServices
TelnetServices
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
NO :)
NO WAY!

CSV is just text file, it CANNOT contain format
If you want to create a file in PHP to view in Excel I would recommnd PHPExcel. It can output to XLSX (Office 2007/2010) and is quite good for the purpose.
Avatar of Richard Korts

ASKER

To TelnetServices:

Should the output file being created in php have an .xls extension or htm (or html)?

I presume I just build html tables in the body to represent the Excel equivalent?

Can I use embedded CSS (not a separate css file, but in the html)?

This sounds like an EXCELLENT solution.

Thanks!
Works VERY easily!
Sorry - missed your comment - but yes basically all the formatting (more or less) will come through as you expect it to.

Glad it works for you - thx for the points :)

Steve
TelnetServices:

The only thing it does that's sort of odd is that one column is (on some rows) moderately lengthy text, it wraps the cell so a FEW of the rows are "double deep" (in Excel).

I'm thinking of trying to overcome this by determining the maximum width I will need (based on font & number of characters in text) & set a html width parameter for that column based on that value.  

Think that would work?

Thanks
I think so - the issue is with excel, it tries it's best to maintain the look of the document (rather than maintain structure as such)

Give it a go.
To TelnetServices:

I'm trying to add other formatting. Specifically, row background color. I tried using the traditional <tr bgcolor="hex value">. It puts the background color at dark gray, no matter what.

I also used css style, same result.

Any thoughts?

Maybe I have to do it at the <td> level?

Thanks