question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Newline characters in cells of written workbooks

See original GitHub issue

When values v of cells contain unix line endings \n they do not become line breaks in the corresponding cells of the written workbook. However, when the Windows carriage return newline combos \r\n are used Excel appears to properly break the lines when a cell containing them is double clicked (edited).

screen shot 2014-09-11 at 11 44 40

So there appear to be two things to potentially address here:

  1. Unix line endings \n do not become new lines at all in the written file
  2. Windows line endings \r\n only become newlines in Excel when the cell is edited. This may be a shortfall in Excel for Mac 2011 and may not apply to the Windows version.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

8reactions
qqilihqcommented, Nov 8, 2018

Did someone find a workaround? We the same issue on Excel macOS and Excel Windows – text is shown in a single line and changes on double click.

Apple Numbers shows the file correctly.

6reactions
fozcodecommented, Mar 24, 2020

I could only get this working correctly using the Pro edition where the saving of cell styles is supported. It needed: \n in the string value, bookSST: true, cellStyles: true in XLSX.write, and cell.s = { alignment: { wrapText: true } } in the cell style.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add Find and Replace Line Breaks in Excel - Contextures
On the keyboard, press Ctrl + J to enter the line break character. NOTE: Nothing will appear in the Find What box. Click...
Read more >
Start new line in Excel cell - 3 ways to add carriage return
Three ways to insert a line break in Excel cell: enter multiple lines ... CHAR(10) adds a carriage return between each combined text...
Read more >
get a line break / new line in excel file with r xlsx - Stack Overflow
Apply it to the cell: setCellStyle(cell_b_2, cs). Save the workbook: saveWorkbook(wb, 'df.xlsx'). The resulting workbook looks like this:.
Read more >
How to Insert Line Break in Excel (Quick and Easy)
Using Define Name Instead of Char(10) · Click the Formulas tab · Click on the 'Define Name' option. Insert Line Break in Excel...
Read more >
Quick Tip: Find and Replace Line Breaks in Cells
To show text on separate lines in an Excel worksheet cell, use a shortcut, Alt+Enter, to add a line break. If you want...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found