Tom
Tom

Reputation: 721

Exporting from PHP to Excel - cell formatting

I am exporting data from a database to an Excel file using PHP and a Codeigniter to_excel helper.

Everything is working correctly, except I have a field that contains data in the format of 1-1, 2-1 etc. When I open the file in Excel, Excel is automatically formatting this data as a date field so that it appears 01-Jan, 02-Jan etc.

Is there a way to force Excel not to format this data as a date field?

Thanks.

Upvotes: 1

Views: 2722

Answers (1)

Rachel Hettinger
Rachel Hettinger

Reputation: 8442

Preface the data with a single apostrophe so that Excel treats it as text. This needs to be done before it is opened in Excel.

Upvotes: 2

Related Questions