Jump to content

Format cell on .csv outfile file


nashsaint

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.