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
https://forums.phpfreaks.com/topic/249117-excel-csv/
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
https://forums.phpfreaks.com/topic/249117-excel-csv/#findComment-1279534
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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