Reputation: 2980
I'm building Excel template to get data about products from our users. The problem is that there are certain fields number of which can vary.
For example, product can have 1 contributor or 12 contributors. Each contributor have the following fields:
I don't think is good idea to include 12 * 4 columns to Excel template, because on the next day user can send product which has 13 contributors.
I decided that I will include data about all contributors in one cell, for example in cell "Contributor Key Name" I will have name of all product contributors, in cell "Contributor Role" I will have roles of all contributors etc.
I wanted to divide contributors data by new line symbol. I created Excel table with the following data:
The problem is that when I read value of these cells ("Contributor Key Name" for example) in PHP I don't see new line symbol. Instead I receive string with strange characters:
I tried to do
explode('\n',$cellValue);
but it doesn't work.
I use PHPExcel library for working with table.
My question is - how new line symbol is encoded in Excel? What would you recommend to use as delimiter in Excel cells?
UPD:
So, in order to divide strings by new line character you should use "\n" as delimiter.
I think, that strange symbols appeared in my string because initially I created table in Numbers app and then export to xslx format. (Numbers has some problem with new line character during export)
Upvotes: 1
Views: 9188
Reputation: 212412
In PHP, '\n'
(in single quotes) is a literal \
character followed by a literal n
character. "\n"
(in double quotes) is a newline character
Upvotes: 9