R:如何使用XLConnect的setCellFormula函数编写非英语的excel公式?

时间:2018-07-03 09:18:57

标签: r excel xlconnect

当我使用XLConnect和setCellFormula将德语的excel公式写入工作簿时,相应的单元格在公式中显示了未解析名称的错误(显示为“ #NAME?”)。当我打开工作簿时,输入单元格并按Enter键,公式将起作用。

我的代码有问题吗?所有这些都在Windows 7和Excel 2010上进行。

library(XLConnect)
out_wb <- loadWorkbook("test.xlsx", create = TRUE)

createSheet(out_wb, name = "test_data")
writeWorksheet(out_wb, "test_data", header = FALSE, data = 1:50)

createSheet(out_wb, name = "test_calc")

# german formula - cells gives '#NAME?'-error. Result not displayed until you enter the cell and leave it with ENTER
setCellFormula(out_wb, sheet = "test_calc", row = 1, col = 1, formula = "SUMME(test_data!A2:A10)")

# english formula - works as expected 
setCellFormula(out_wb, sheet = "test_calc", row = 2, col = 1, formula = "SUM(test_data!A2:A10)")

# recalculation does not solve the issue
setForceFormulaRecalculation(out_wb, sheet = "test_calc", TRUE)

saveWorkbook(out_wb)

手动翻译公式不是一种选择,因为公式很多,并且源自文本文件。任何帮助表示赞赏。

0 个答案:

没有答案