views:

405

answers:

3

Hi, I am generating a simple csv file using php. The file contains some user's personal data. When I open the generated file in office, the addresses are not displayed in full height. I have to double click on the cell for the address to be shown fully (in full width and height) otherwise I can only see the first word/number of the address. Also, I have date of births displayed as ######, I have to expand the whole column to see them fully.

This doesn't happen in open office.

Is there any way to force MS Office to show all fields in full? Because otherwise it'll be to confusing for the people who will use (Hey where are all the details!:)

Thanks :)

+2  A: 

I don't think you can "format" your sheets with CSV. You will have to produce some other file format that Excel understands. I would suggest XML which is really easy to generate. Just make a sample sheet with the data you want, save it as XML and you'll see how your file should be generated. Or you could use some ready-made PHP solution for writing excel files if you can't be bothered with analysing the XML file.

Jan Hančič
A: 

you could try the auto-size columns feature.

twolfe18
A: 

This is a UI issue with how Excel works, you can't force Excel or anything else how they handle it.

The quickest work around is to perhaps create an XLS file that runs a macro to retrieve the CVS file and format the cells as needed, but there's nothing you can do inside the CSV to affect what Excel is displaying.

TravisO