Search code examples
phpexcelcsvexport-to-excel

CSV files and multi line text cells


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 :)


Solution

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