New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newlines are not preserved #202
Comments
Works perfectly fine, the cell has a newline in it. If you can provide a minimal code that exhibits the behavior you are talking about, please provide and reopen. |
Many thanks for the quick response. On Mac, I could get it working by using "\r" instead of "\n", however that was not compatible with Windows. Lastly "\r\n" works on Windows, but adds an additional space on the beginning of every new line on Mac. I have tried to create a file sheet manually with Excel and it was cross-os compatible. Any ideas? |
I strongly suspect that the reason is that Excel uses shared strings instead of inline values that But, can you provide the minimal files for both platforms so I can take a look at the differences beween them? Create a new document, type "a(alt-enter)b" into the very first cell, save them and give to me. |
Of course I can, and many thanks for your help already! The first file was created with Excel 2013 on Windows, the second file with Excel 2016 on Mac. https://www.dropbox.com/s/drbgwece5x5u9g2/Windows.xlsx?dl=0 |
Found it. The problem lies with |
I have a strong suspicion that we have with 2 minor bugs complementing each other creating a "perfect storm" condition here:
It's the presence of both of these bugs that creates the effect that you see; if any one of them is removed from the equation, the effect disappears. I'm afraid I have little to no control over either. |
This sounds to me that "\n" should work for line-break on Mac, while "\r" shouldn't, or am I mistaken here? Unfortunately, it's the other way round. Using "\r" gives proper line-break (only on Mac, not on Windows), while "\n" is converted into white-space on Mac. |
Perfect! That's the last piece of the puzzle I was missing, and now I have a clear picture of what's going on!
|
Ah! That finally makes it clear to me, too. The workaround that I have found for now is to use "\n\r" in my script, which is a little counter-intuitive but gives working line-breaks on both platforms with the only disadvantage of adding a trailing whitespace to each line which doesn't hurt in my particular use-case. |
So, from the conversation in sparklemotion/nokogiri#1356, we conclude:
Because of that, there's no good way to solve this issue. The only reasonable way I see is to persuade the authors of So it looks like I don't have a good way to solve this. :( |
I tried to write a cell with multiple lines, but despite setting text_wrap to true as suggested in another tickets, my newlines are ignored and seemingly converted to spaces.
This is an extract of the code I'm using:
The text was updated successfully, but these errors were encountered: