Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    342
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Saving data in CSV in PHP

    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...

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    You can't do any formatting with CSV.
    CSV is plain text only.

    Use XML instead:
    http://www.ibm.com/developerworks/op...y/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/20...ML-format.html

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



    .
    Last edited by mlseim; 04-24-2012 at 02:01 PM.


  •  

    Posting Permissions

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