Jump to content

Excel CSV


Nodral

Recommended Posts

Hi

 

I'v a script that generates a CSV file which the user then downloads in Excel.  Is there a way of setting column widths in the excel.csv file prior to opening?  Some of the data generated is longer than the standard column width and the user is expected to print the file.  I can't rely on the user having enough 'grey matter' to realise they will have to increase the width prior to printing!!

Link to comment
Share on other sites

Actually you can set the widths by putting your data in a table use this format in your headers

 

// Convert page to xls document
header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=filename.xls");

 

Then set out the rest of the page in a table keeping the width to your page width, I have used this method for tax reporting software and works fine.

 

You are also able to change background colors of cells and include borders if you wish.

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.