awalker89 / openxlsx

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

getTables - character & changing on sheet name #508

Open allanbides opened 4 years ago

allanbides commented 4 years ago

Hello, guys,

I am using the function getTables, to discover the tables on Sheet "T&O", but I receive the message that this sheet does not exist, because the function in some way looks for the sheet 'T& amp;O' , changing the '&' by ' & amp;'(even here it was hard to write, I needed to put a space)

 getTables(wb,"T&O")
 Error: Sheet 'T&O' does not exist.

Any suggestions?

Thanks in advance!

Allan

sessionInfo()

jsavinc commented 4 years ago

I'm experiencing the same issue with openxslsx version 4.1.5 and R 4.0.0! I get the error with & and < characters, when with a previous version they worked fine (just updated today so not sure what version I was using previously).

jsavinc commented 4 years ago

See below example:

wb <- openxlsx::createWorkbook()
openxlsx::addWorksheet(wb, sheet = "a < 1")  # this works
openxlsx::writeData(wb, sheet = "a < 1", jams)  # this returns an error

I can add a worksheet containing a special character, but when using writeData(), the sheet name first gets validated using validateSheet() which renames special characters using replaceIllegalCharacters(), but then checks against the existing sheet names (containing said character) and doesn't find the matching sheet. I don't know why the characters get replaced in one method but not the other?

ycphs commented 4 years ago

Hi,

That is the old repository for this R Package.

Please use the new one:

https://github.com/ycphs/openxlsx