SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot sajjad's Avatar
    Join Date
    May 2005
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    If you lose your patience you lose half of battle

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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.
    Saul

  3. #3
    SitePoint Zealot sajjad's Avatar
    Join Date
    May 2005
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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,
    If you lose your patience you lose half of battle

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    As I said, that's not possible in CSV.
    Saul

  5. #5
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    Visit my blog
    PHP && Life
    for technology articles and musings.

  6. #6
    SitePoint Guru
    Join Date
    Jul 2005
    Location
    Orlando
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excel also reads HTML. Build a table in HTML and open it in Excel..

  7. #7
    SitePoint Zealot Amenthes's Avatar
    Join Date
    Oct 2006
    Location
    Bucharest, Romania
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  8. #8
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,561
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Write your excel files using http://pear.php.net/package/Spreadsheet_Excel_Writer/ that lets you set wide range of formatting option.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •