ropensci / writexl

Portable, light-weight data frame to xlsx exporter for R
https://docs.ropensci.org/writexl
Other
210 stars 17 forks source link

newline characters get converted to hex strings #22

Closed mgacc0 closed 6 years ago

mgacc0 commented 6 years ago

When trying to write strings that contain newline symbols, they get translated to an hex representation.

For example:

> v1 <- data.frame(CONFIGITEM_NUMBER = 1161014163, Note = "Nuevo disco SSD\r\n\r\nMon")
> v1
  CONFIGITEM_NUMBER                       Note
1        1161014163 Nuevo disco SSD\r\n\r\nMon
> write_xlsx(v1, "file.xlsx")

The carriage return symbol gets converted to _x000D_. And the newline symbol gets converted to a blank space.

CONFIGITEM_NUMBER Note
1161014163 Nuevo disco SSDx000D _x000D_ Mon

I'm not sure if this is caused by libxlsxwriter or by writexl.

jeroen commented 6 years ago

@jmcnamara

jmcnamara commented 6 years ago

This is the correct behavior in terms of terms of how Excel behaves. It encodes \r to _x000D_ in the XML. \n is stored as the character \n.

However, it shouldn't be visible in Excel. Are you saying that it is?

mgacc0 commented 6 years ago

Reading the OOXML specs, I've just discovered that this is the expected behaviour. It's a bug in LibreOffice Calc.

The symbols _x000D_ are not visible in Excel but they are visible in LibreOffice. Thanks.