In R, I have a data.table that I read from an excel file that has the following records:
- good morning World
- good afternoon world
Both lines are separated by a carriage return \r\n in Excel. I am using a word template that I read with the read_docx function. Using the body_replace_all_text function I want to replace the content of the templates with the 2 lines of the excel sheet, what happens to me is that I cannot make the two lines separate in the Word sheet
example <- read_docx("C:/WORKSPACE/example.docx") #read the template from MS World ''' Requested information «Requested_information» ''' df <- read_excel("C:/WORKSPACE/df.xlsx",sheet='Sheet1') #read the following text separated by \r\n '''
- good morning World
- good afternoon world '''
doc <- body_replace_all_text(example, old_value = "«Requested_information»",new_value = df$"Requested Information", only_at_cursor=FALSE, ignore.case = TRUE) print(doc, target = "C:/WORKSPACE/output.docx")
I am getting the following MS Word Document: Requested information
- Good Morning World - Good Afternoon World
But I need: Requested information
- Good Morning World
- Good Afternoon World
So I am not able to write in 2 different sentences in the MS Word document