while working on an export to Excel I discovered the following problem.
If you create a table where one cell has a line break and you save the document as a txt file it will look like this:
"firstLine<LF>secondLine"<TAB>"secondColoumn"
When I open this file in Excel the line break is gone and the first row has only one cell with the value firstLine
Do you know if it is somehow possible to keep the line breaks?
EDIT: Applies to Excel2010. Don’t know if other versions behave different.
EDIT2: Steps to reproduce:
- Open blank excel sheet
- Enter text (first column with line break, second colum not important)
- Save as Unicode Text (txt) // all other txt don’t work as well
- Close Excel file
- File->Open
- No changes in the upcoming dialog.
The excel file has now 2 rows which is wrong.
I was finally able to solve the problem! yay 😀
CSV:
The german Excel needs a semicolon as a separator. Comma doesn’t work.
Note: This is only true when the file is encoded as UTF-8 with BOM at the beginning of the file. If it’s ASCII encoded comma does work as a delimiter.
TXT:
The encoding has to be UTF-16LE. Also it needs to be tab delimited.
Important:
The files will still be displayed incorrect if you open them with the “File->Open” dialog and “import” them. Draging them into Excel or opening with double click works.