首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >flextable和officedown错误: read_docx仅支持docx文件

flextable和officedown错误: read_docx仅支持docx文件
EN

Stack Overflow用户
提问于 2020-10-01 23:15:41
回答 1查看 158关注 0票数 0

flextable和officedown会产生一个错误: read_docx只支持docx文件出现在使用officedown的最小尝试中。我见过这个post,但是我的文件路径没有空格,所以这似乎不是问题所在。

代码语言:javascript
复制
---
date: "`r Sys.Date()`"
author: "Your Name"
title: "officedown template"
output: 
  officedown::rdocx_document:
    mapstyles:
      Normal: ['First Paragraph']
---

knitr::opts_chunk$set(echo = TRUE, fig.cap = TRUE)
library(officedown)
library(officer)
library(flextable)

fp <- fp_par(
  text.align = "center", 
  padding.bottom = 20, padding.top = 120, 
  border.bottom = fp_border())

ft <- fp_text(shading.color='#EFEFEF', bold = TRUE)

flextable(mtcars)
代码语言:javascript
复制
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_1.4.0.2        flextable_0.6.0.002  officer_0.3.14       officedown_0.2.1.001

loaded via a namespace (and not attached):
 [1] xfun_0.17         remotes_2.1.1     testthat_2.3.2    miniUI_0.1.1.1    htmltools_0.5.0  
 [6] usethis_1.6.1     yaml_2.2.1        base64enc_0.1-3   rlang_0.4.7       pkgbuild_1.0.8   
[11] later_1.1.0.1     glue_1.4.2        withr_2.2.0       gdtools_0.2.2     sessioninfo_1.1.1
[16] uuid_0.1-4        zip_2.1.1         devtools_2.3.0    memoise_1.1.0     evaluate_0.14    
[21] knitr_1.30        callr_3.4.3       fastmap_1.0.1     httpuv_1.5.4      ps_1.3.3         
[26] fansi_0.4.1       Rcpp_1.0.5        xtable_1.8-4      promises_1.1.1    backports_1.1.7  
[31] desc_1.2.0        pkgload_1.1.0     jsonlite_1.7.1    mime_0.9          systemfonts_0.3.2
[36] fs_1.4.1          digest_0.6.25     processx_3.4.2    rprojroot_1.3-2   here_0.1         
[41] cli_2.0.2         tools_4.0.2       magrittr_1.5      whisker_0.4       crayon_1.3.4     
[46] ellipsis_0.3.1    data.table_1.12.8 xml2_1.3.2        prettyunits_1.1.1 rvg_0.2.5        
[51] reprex_0.3.0      assertthat_0.2.1  rmarkdown_2.4     rstudioapi_0.11   R6_2.4.1         
[56] compiler_4.0.2 
EN

回答 1

Stack Overflow用户

发布于 2020-10-19 10:19:12

嗨,杰西卡和大卫·戈赫尔,

我看到this post在使用flextable时出现了与read_docx相同的错误。基于Mike M的巨大努力,问题最有可能来自文件路径

我已经修复了我的问题,因为我终于在我的用户名中找到了一个空格,所以officedown生成的模板的文件路径将被复制到C:\Users\Myfirstname Mygivenname\AppData\something_else。那么在终端中,它将是C:\Users\Myfirstname~Mygivenname\AppData\something_else,并且会出错。这可能是Windows用户的问题,因为我已经在我的Mac上尝试了同样的东西,并且它可以工作。

因此,请确保您的用户名(或整个文件路径)没有任何空格

感谢大卫的officedown包和Mike M。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64158319

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档