awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
365 stars 78 forks source link

writeFormula adding an "@" symbol between formulas #519

Open wwyws0000 opened 4 years ago

wwyws0000 commented 4 years ago

Hi, I'm trying to write a formula to the spreadsheet that takes the sum of absolute values of a range (say, cell A2:A11).

I.e, the desired formula is SUM(ABS(A2:A11))

Expected Behavior

Using writeFormula(), I expected the resulting formula to be exactly that

Actual Behavior

However, the actual formula in the resulting Excel spreadsheet is =SUM(ABS(@ A2:A10))

There's a "@" that came out of nowhere and it's messing up the calculation

This is likely due to interactions with Excel's spill/dynamic array features.

Steps to Reproduce the Problem

wb <- createWorkbook()
addWorksheet(wb,'Test')
testMat <- matrix(rep(10,10),10,1)
writeData(wb,'Test',testMat)

testFormula <- 'SUM(ABS(A2:A11))'
writeFormula(wb,'Test',testFormula,startCol = 1,startRow = 13)

saveWorkbook(wb,'test.xlsx',overwrite = T)

sessionInfo()

R version 3.6.2 (2019-12-12) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17763)

openxlsx_4.2.2

Excel: Microsoft Office 365 ProPlus

ycphs commented 4 years ago

Could you please create this also at ycphs/openxlsx?

I am maintaining the active fork of the package.

wwyws0000 commented 4 years ago

Yep I submitted another post there. Thank you!