awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
363 stars 79 forks source link

@ is added when writing formula to excel #507

Closed geebioso closed 4 years ago

geebioso commented 4 years ago

Hey awalker89,

Thank you for the package. It's super useful.

Expected Behavior

use writeForumla to write and excel formula taking the average of the absolute value of a range of cells. E.g., write "AVERAGE(ABS(A1:A10))" to cell B1.

Actal Behavior

an '@' is appended to the beginning of the cell range. E.g., "AVERAGE(ABS(@A1:A10))"

Steps to Reproduce the Problem

library(openxlsx)

openxlsx::addWorksheet(workbook, "Sheet1")
openxlsx::writeData(workbook, sheet = "Sheet1", 1:10)
openxlsx::writeFormula(workbook, sheet = "Sheet1", startCol = 2, "AVERAGE(ABS(A1:A10))")

openxlsx::saveWorkbook(workbook, file = "test.xlsx", overwrite = TRUE)

Thanks for your time!

sessionInfo()

R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.4

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
[1] compiler_3.6.1 tools_3.6.1    packrat_0.5.0 
geebioso commented 4 years ago

solution here