New line in richText cell
See original GitHub issueTake the following code:
let excel = require('exceljs')
let wb = new excel.Workbook()
let ws = wb.addWorksheet('test')
ws.getCell('B2').value = {
richText: [
{
font: {
color: {
argb: `99E391`
}
},
text: `Chuck Norris' tears cure cancer,\n`
},
{
font: {
color: {
argb: `FF6565`
}
},
text: `too bad Chuck Norris has never cries.`
}
]
}
wb.xlsx.writeFile('./test.xlsx').then(err => {
if (!err) {
console.log(`file written successfully.`)
} else {
console.log(`error writing file: ${err}`)
}
})
The result will be a string resembling the following (Ignoring the line break):
Chuck Norris’ tears cure cancer,too bad Chuck Norris never cries.
It seems as though the line break is being stripped from the ends of the text property when the file is being written.
By simply adding a character after the \n the line break does not get removed. Is there a setting somewhere to turn this functionality on or off?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
how to insert a new line programmatically in a richtextbox ...
In my last example you could see i select the new text and set all the format properties to the value of the...
Read more >New line code in formula rich text field | Discussions
Hi, I'm trying to add an image thumbnail and text together on a report, and want the text to be under the image....
Read more >Update Rich Text Content Control with String and New ...
I am passing a string with \n (like “Hello\nWorld”) to a method that sets the Rich text control in Java but the string...
Read more >How to append \line into RTF using RichTextBox control
Paragraph myParagraph = new Paragraph(); FlowDocument myFlowDocument = new FlowDocument(); // Add some Bold text to the paragraph myParagraph.
Read more >Excel - Insert a Line Break in a Cell
This one is easy. While you're editing the text of a cell, you can simply press Alt+Enter (or Command+Option+Enter for Mac) to add...
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
@Siemienik This bug has been fixed by guyonroche, See https://github.com/exceljs/exceljs/commit/493bf3f6b627ed3bbdd0c9ef58f0479c411cc4cc
It works for me, if I change the code in the 3 modules
from:
if (model[0] === ’ ’ || model[0] === ‘\n’ || model[model.length - 1] === ’ ’ || model[model.length - 1] === ‘\n’) { xmlStream.addAttribute(‘xml:space’, ‘preserve’); }