awalker89 / openxlsx

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

read.xlsx() fails when cell has literal "-" #482

Closed tomstockfisch closed 5 years ago

tomstockfisch commented 5 years ago

Expected Behavior

a column with literal "+" and "-" signs expected to be read by read.xlsx() into a data.frame that shows these as text

Actual Behavior

data.frame output has "+" ok, but "-" is converted to NA

Steps to Reproduce the Problem

(please attach an example xlsx file if possible)

1.Type in a column in excel with some cells set to + and others to -

2.save as xlsx

3.read using read.xlsx() write out as csv note that - cells are now empty (+ cells are ok)

Changing Format>cell>Number>[anything] from within excel doesn't help at all.

sessionInfo()

tomstockfisch commented 5 years ago

Sorry, I accidentally subsequently read the data frame back in from a file with read.csv( ..., na.string=c("NA","","-","N/A","#N/A"). read.xlsx() is working fine in this case by itself.