Issue with writing newlines
See original GitHub issueI’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.
var utils = require('exceljs/lib/utils/utils');
utils.xmlEncode = require('entities').encodeXML;
Looking at the xmlEncode
function it does look like it’s wrong, it’s not allowing \n
(0x0A) through.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:19 (7 by maintainers)
Top Results From Across the Web
Writing string to a file on a new line every time - Stack Overflow
Use "\n": file.write("My String\n"). See the Python manual for reference.
Read more >How do you write in a new line on a text file in Python? - Quora
If you are writing a text file, then you are writing strings. Just include a newline character '\n' at the end of the...
Read more >8.8. Writing files — Python for Everybody - Runestone Academy
We must make sure to manage the ends of lines as we write to the file by explicitly inserting the newline character when...
Read more >Write a string to a file on a new line every time in Python
To write a string to a file on a new line every time, open the file in writing mode. Append a newline (`\n`)...
Read more >Reading \n from file doesn't result new line - Forums - IBM
If you really have the to characters "\n" inside your text file (and you are not only writing it this way to highlight...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m on 0.5.1 and this issue isn’t fixed… Edit – okay, you really do still have to use
style: { alignment: { wrapText: true } }
when creating the columnThat will work…
Ok, I think I’ve got a solution working for new lines.
@Rycochet, can you PR the change you posted above, that lets the new line through?Nvm, I PR’d it.With that change, I had to do two other things:
useSharedStrings
anduseStyles
properties:this.workbook = new Excel.stream.xlsx.WorkbookWriter({ useSharedStrings: true, useStyles: true });
wrapText
style property to true:{ header: columnName, key: columnKey, width: 10, style: { alignment: { wrapText: true } } }