我正在尝试上传Excel文件并将其转换为Google表格。但是,如果不先与该单元进行交互,则该公式将不会在Google表格中求值。例如,在下面的示例代码中,仅在公式之后在单元格内部添加一个空格(通过Sheets Web UI)将产生所需的输出(单元格A2和A3中的“ Hola”和“ adios”)。>
library(googledrive)
library(openxlsx)
df <- structure(list(english.to.spanish = c("=GOOGLETRANSLATE(\"hello\", \"en\", \"es\")",
"=GOOGLETRANSLATE(\"goodbye\", \"en\", \"es\")")), row.names = c(NA,
-2L), class = c("tbl_df", "tbl", "data.frame"))
df
english.to.spanish
<chr>
1 "=GOOGLETRANSLATE(\"hello\", \"en\", \"es\")"
2 "=GOOGLETRANSLATE(\"goodbye\", \"en\", \"es\")"
wb <- createWorkbook()
addWorksheet(wb, sheetName = "eng_to_span")
writeData(wb,sheet = "eng_to_span",
x = df)
saveWorkbook(wb, "eng_to_spanish.xlsx", overwrite = TRUE)
progress.sheet <- drive_upload(media = "eng_to_spanish.xlsx",
type = "spreadsheet")
browseURL(drive_link(as_id(progress.sheet$id)))
我需要在100多个电子表格中执行此操作,因此我正在寻找一种编程/脚本解决方案。