0

when i export excel file in R using open xlsx package

if i open excel file it's shown these message:

"We found a problem with some content <nnnn>.xlsx. Do you want us to try and 
 recover as much as we can?"

i think this issue come from Openxlsx package,

this is my code

 openxlsx::write.xlsx( df, file = "NG.xlsx" , sheetName = "df" , col.names = 
 TRUE , row.names = FALSE )

how can i solve this problem in R ?

Mj___3
  • 13
  • 8
  • 1
    without data `df` or something similar that produces an error its impossible to say. – Andre Elrico Dec 03 '18 at 07:49
  • @Konrad there is no such thing as the output data.frame. I'm talking about `df` the input data.frame to the function. – Andre Elrico Dec 03 '18 at 09:07
  • 1
    Have a look at [this discussion](https://github.com/awalker89/openxlsx/issues/185). Using `stri_trans_general` and `stri_escape_unicode` may be enough to remove offending characters from your data frame. – Konrad Dec 03 '18 at 09:10
  • are you able to open it in Excel without any warning message? although the file extension is xlsx, the format might not really be xlsx. you can open in text editor like Notepad++ to check – chinsoon12 Dec 03 '18 at 10:03
  • all previous solution did not work :( – Mj___3 Dec 03 '18 at 11:21
  • 2
    @Mj___3: Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung Dec 04 '18 at 05:37
  • I have found that files sometimes seem to have greater number of (empty) columns than possible for libreoffice calc to open. However this is not a real problem - it opens with error message, truncating the empty columns and all is fine. Then I save it and next time it opens without a problem. So try to open in `calc` and see if you get a more informative error message. – r0berts Feb 18 '19 at 07:04
  • I had this issue from having slash characters in the worksheet names. – tauft Jul 20 '22 at 05:21

0 Answers0