nashsaint Posted June 15, 2008 Share Posted June 15, 2008 Hi, This is xurion's code which i got somewhere in this forum. I just want to format the cell of the .csv output file, like cell width, font size.. etc... Please help. Here's the code. <?php require_once ('./mysql_connect.php'); // Connect to the db. //head information for a csv file header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); Header("content-type: text/html"); header("Content-Disposition: attachment; filename=\"tcdisks.csv\";"); header("Content-Transfer-Encoding: binary"); //echo the first line to be the titles of the columns (notice the return at the end of the line) echo '"Job Number","Model Number","Firmware" '; //query the db for the information $result = mysql_query("SELECT * FROM disks ORDER BY job_no"); //echo each record (notice the return at the end of the line) while ($row = mysql_fetch_array($result)){ echo '"'.$row['job_no'].'","'.$row['model_no'].'","'.$row['firmware'].'" '; } ?> Link to comment https://forums.phpfreaks.com/topic/110292-format-cell-on-csv-outfile-file/ Share on other sites More sharing options...
CodeJunkie88 Posted June 15, 2008 Share Posted June 15, 2008 Hi! With .csv files, I don't think you can include any formatting information that Excel would recognize. Try loading a .csv file in excel, format the cells (change fonts, column widths, etc.) then try saving the file. Excel will warn you that you will lose any formatting if you proceed to save the file as a .csv file. Link to comment https://forums.phpfreaks.com/topic/110292-format-cell-on-csv-outfile-file/#findComment-565921 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.