How to insert a line break in word

Bin Hua 6 Reputation points
2022-08-22T06:00:16.267+00:00

Hello,

I am trying to create a word add-in, there's a textarea on its pane, I need to insert the content in this textarea to word.

my code

   const content = document.getElementById("tacontent").value;  
   context.document.body.insertParagraph(content, Word.InsertLocation.end);  
   await context.sync();  
 

But when I am trying to insert some words with line break like following

   123  
   456  
   098  

They will be displayed like following on word

   123\n456\n098  

The break lines were turned into a string \n.

How can I fix this, thank you.

Microsoft 365 and Office | Development | Office JavaScript API
Microsoft 365 and Office | Development | Other
0 comments No comments
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.