Forum Discussion

Tie CHENG's avatar
Tie CHENG
Brass Contributor
Jul 30, 2021
Solved

Enter newlines in a cell by JavaScript API

When editing a string value in a cell, we could well use Alt+Enter to enter a newline.

However, when we write a string into a cell by JavaScript, newlines (i.e., `\n`) are ignored. I'm trying the following custom function, we see that what is displayed in the cell does not have newlines.

 

 

/**
* Test2
* @customfunction
* @param {number} a number
* @returns {string} the result
*/
function Test2(n) {
const xxx = "11111\n22222\t33333\r44444 55555"
console.log(xxx)
return xxx
}

 

 

 

Does anyone know how to enter newlines into a cell by JavaScript API? Is there any workaround?

Resources