-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Issue with writing newlines #296
Comments
This was actually one of the things that was fixed in 0.4.2 - a2d2ce6 - check that you're actually using the right version. |
I too have this problem. Using 0.4.6. |
I'm using v0.4.3 and was having a problem with new lines problem - line breaks don't appear in Excel
Line breaks would only appear if I opened in Numbers on macOS. Line breaks would not appear in Excel Viewer, Excel Online, or Excel on Windows 10. By adding a space before workaround
|
@mrmusa Where is your workaround code located? Is that within the library or your own code? I have added a space before the \n characters and there is no change. All newlines are still being stripped. For some reason, sometimes the newlines will stay. Most of the time they don't. I've tried modifying the ExcelJS.js file directly, but that doesn't seem to have changed a thing. |
Are you using v0.4.3?
…On Sun, Jun 11, 2017 at 7:28 PM Shiva Velingker ***@***.***> wrote:
@mrmusa <https://github.com/mrmusa> Where is your workaround code
located? Is that within the library or your own code?
I have added a space before the \n characters and there is no change. All
newlines are still being stripped. For some reason, sometimes the newlines
will stay. Most of the time they don't. I've tried modifying the ExcelJS.js
file directly, but that doesn't seem to have changed a thing.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#296 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAgRJzmISghl74kovGvsbKHvI16DCRaSks5sDHgagaJpZM4Muz0g>
.
|
@mrmusa I'm using v0.4.11 but can switch to v0.4.3 if that's how you got it to reliably work |
@shivavelingker - Yes that's the only version I've used. I haven't upgraded due to some changes here which cause exceljs to fail my build. I don't have anytime to look into it so I'm sticking with the version that works. Did upgrading help? |
v0.4.11 didn't work for me and neither did v0.4.3 (I'm not sure if your changes were to the docs or to your own code, so I didn't modify anything). I've just downgraded to v0.2.38 until this issue gets resolved, if ever. It seems to be working well for me. |
Considering that it's an MS product, could it be that it's specifically wanting |
I'm also having an issue with this. I'm specifically passing in \r\n and it's not separating values by a new line when opened in Excel. |
From what I can tell, the PR mentioned above doesn't actually let new lines through. When I stream the data to create a workbook, I'm manually pushing CR+LF when parsing arrays, something like this:
Which would give something like: When I get to the xmlEncode function referenced here, I can see in the debugger that there is in fact a line break in However, it's hitting the 'default' case of that switch, so it's just replacing it with an empty string. I've tried updating that code to handle line breaks (adding a case checking Would love any kind of guidance on this. |
What's weird is that I did that PR, and using it here lets them through, hence my wondering if it could be character encoding somewhere... Ugh - looking at it, the return text.replace(/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/g, function (c) { If that doesn't in fact fix it, then might be worth standardising the output and replacing any (Just to note, I actually looked at the XML specs, hence changing the ranges, wasn't looking at the actual character codes). |
That does allow the new line to get through, but it appears to still be getting stripped out somewhere unfortunately. Are you able to actually see the new lines in the resulting Excel file? Do you happen to have any examples of the code you're using to test? And/or an output Excel file? |
@Rycochet I tried that myself a couple weeks ago, but it didn't work for me. Nor did having a separate case for new lines work either. Even if I took out the text replacement for the entire range |
Ok, I think I've got a solution working for new lines.
With that change, I had to do two other things:
|
Just pushed 0.4.13 which should fix this |
I'm on 0.5.1 and this issue isn't fixed... That will work... |
@guyonroche @Rycochet @holly-weisser |
@guyonroche @Rycochet @holly-weisser |
I have the same problem too |
Thank you for saving my day. |
I'm having an issue writing
\n
to cells. It's stripping them from the file. I'm using version 0.4.2.When I monkey patch exceljs to use the
entities
module, it works correctly.This is not a permanent fix, just demonstrating how to patch it.
Looking at the
xmlEncode
function it does look like it's wrong, it's not allowing\n
(0x0A) through.The text was updated successfully, but these errors were encountered: