awalker89 / openxlsx

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

saveWorkbook vs write.xlsx : alphanumeric char are displayed as dots #435

Closed K0nj closed 5 years ago

K0nj commented 5 years ago

I tried writing the same data set (extracted from my sql db using markdown script) with the two methods:

the first option:

write.xlsx(sqlreslist,filenamepath)

the second option:

writeData(wb,sheets[i],as.data.frame(datasources[i]), xy=c(startcol,startrow), colNames = TRUE, rowNames = FALSE, headerStyle = hs, keepNA = FALSE, borders = "surrounding", withFilter = TRUE)

wb <- createWorkbook()

writeData(wb,sheets[1],as.data.frame(datasources[1]), xy=c(startcol,startrow), colNames = TRUE, rowNames = FALSE, headerStyle = hs, keepNA = FALSE, borders = "surrounding", withFilter = TRUE)

saveWorkbook(wb,filenamepath, overwrite = TRUE)

Expected Behavior

IgG Quotient (tigg-q) / Einheit: *10^-3

Actual Behavior

IgG.Quotient..tigg.q....Einheit...10..3

Steps to Reproduce the Problem

It could have to do w. the locale encoding or collation. Are both function using the same source? Is there any option to force the encoding ? (could not find anything in the documentation)

sessionInfo()

R version 3.5.1 (2018-07-02) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)

K0nj commented 5 years ago

I could solve the issue by calling the df in my df list with [[i]] instead of [i]. Then I guess the issue is not coming from a difference between the functions but rather a misunderstanding of R grammar from my side.

thanks for this very awsome pckg