Skip to content

write.xlsx does not error if it doesn't have write permissions #190

@jeff-m-sullivan

Description

@jeff-m-sullivan

Describe the bug
If write.xlsx is asked to write out data to a file that the user doesn't have write permissions to, it fails silently.

To Reproduce
Steps to reproduce the behavior:

> fs::file_create("foo.xlsx", mode="a=rx")
> openxlsx::write.xlsx(x=cars, file="foo.xlsx", overwrite=TRUE)

Expected behavior
It should throw an error, like write.csv does:

> fs::file_create("foo.csv", mode="a=rx")
> write.csv(cars, file="foo.csv")
Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
  cannot open file 'foo.csv': Permission denied

This was using the latest CRAN version: 4.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requestedwaiting for answerIf not answered, the issue will be closed in 7 days.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions