Nodral Posted October 14, 2011 Share Posted October 14, 2011 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!! Quote Link to comment Share on other sites More sharing options...
silkfire Posted October 14, 2011 Share Posted October 14, 2011 Export it as an XLS. You will not have control of width with a CSV file, it's pure data. Quote Link to comment Share on other sites More sharing options...
dragon_sa Posted October 15, 2011 Share Posted October 15, 2011 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.