[英]How to delete blank line at beginning of docx from officer
I am using officer
for R
to create aa Word (docx) document. 我正在使用R
officer
来创建Word(docx)文档。 Here is the code: 这是代码:
library(officer)
library(magrittr)
my_docx = read_docx() %>%
# cursor_begin() %<>%
body_add_par("Hello here is a test sentence to see if there is a blank line above it.", style = "Normal") %>%
print(target = "test.docx")
It creates a docx document that has a blank line at the top above the sentence. 它会创建一个docx文档,该文档在句子上方的顶部带有空白行。 It isn't spacing before the font style that is set in the Style of the font. 在字体样式中设置的字体样式前没有空格。 I have uncommented cursor_begin()
but the blank line remains. 我没有对cursor_begin()
进行注释,但是仍然保留空白行。 How can I get rid of this? 我该如何摆脱呢?
Any help is appreciated! 任何帮助表示赞赏!
To delete a paragraph, you need to use function body_remove()
. 要删除一个段落,您需要使用body_remove()
函数。 See documentation here: https://davidgohel.github.io/officer/articles/word.html#remove-content 请参阅此处的文档: https : //davidgohel.github.io/zh-CN/articles/word.html#remove-content
library(officer)
library(magrittr)
my_docx <- read_docx() %>%
cursor_begin() %>% body_remove() %>%
body_add_par("Hello here is a test sentence to see if there is a blank line above it.",
style = "Normal") %>%
print(target = "test.docx")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.