I need to insert a multiline cell with module excel4node, in documentation I didn't found anything about this.
I tried to insert the escape sequence "\n"
but it didn't work. This is my code:
var xl = require('excel4node');
var wb = new xl.Workbook();
var ws = wb.addWorksheet('Sheet 1');
ws.cell(1, 1).string('first line \n second line');
And this is the result inside the cell:
first line \n second line
Somebody knows how it's possible to insert a multiline cell? Which char must I use?
I need to insert a multiline cell with module excel4node, in documentation I didn't found anything about this.
I tried to insert the escape sequence "\n"
but it didn't work. This is my code:
var xl = require('excel4node');
var wb = new xl.Workbook();
var ws = wb.addWorksheet('Sheet 1');
ws.cell(1, 1).string('first line \n second line');
And this is the result inside the cell:
first line \n second line
Somebody knows how it's possible to insert a multiline cell? Which char must I use?
Share Improve this question edited Mar 10, 2020 at 11:53 matthias_h 11.4k9 gold badges23 silver badges40 bronze badges asked Mar 9, 2020 at 17:07 AlTheLazyMonkeyAlTheLazyMonkey 1,2421 gold badge10 silver badges22 bronze badges 06 Answers
Reset to default 7My friendo
Have you tried this way?
ws.cell(1, 1).formula('="first line"&CHAR(10)&"second line"');
I've encountered this problem some time ago. I resolved with:
ws.cell(1, 1).formula('="first line"&CHAR(10)&"second line"');
Helped a colleague yesterday who was having the same issue, after a while we came up with this solution.
ws.cell(1, 1).formula('="first line"&CHAR(10)&"second line"');
I use this to insert breaklines
ws.cell(row, col).string('text to print \n another line').style({ alignment: { wrapText: true});
I've tried alignment and it works
const style = ws.createStyle({
alignment: {
wrapText: true,
},
})
ws.cell(4, 2).string('new\nline').style(style)
There are many ways. I hope this could help. By this code, you can also format a specific line
var complexstring = [
'line1\n',
{
bold: true,
size: 7,
name: 'Arial',
italics: true,
value: 'line2'
}
]
ws.cell(4, 2).string(complexstring)