Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding data with a hyperlink column in a tibble causes an error #893

Closed
dhicks opened this issue Jan 16, 2024 · 1 comment
Closed

Adding data with a hyperlink column in a tibble causes an error #893

dhicks opened this issue Jan 16, 2024 · 1 comment
Labels
Third party 📦 Using or impacting external library or software

Comments

@dhicks
Copy link

dhicks commented Jan 16, 2024

openxlsx2 version 1.3

# Works correctly
df = data.frame(url = 'http://foo.bar')
class(df$url) = 'hyperlink'
wb_workbook() |> 
    wb_add_worksheet() |> 
    wb_add_data(x = df)

# Same thing, but now the dataframe's wrapped in a `tibble`
tbl = tibble::tibble(url = 'http://foo.bar')
class(tbl$url) = 'hyperlink'
wb_workbook() |> 
    wb_add_worksheet() |> 
    wb_add_data(x = tbl)
# Error in `[<-`:
# ! `*vtmp*` must be a vector, a bare list, a data frame, a matrix, or NULL.
@JanMarvin
Copy link
Owner

Hi again @dhicks, looks like our as.data.frame() conversion kicks in to late:

library(openxlsx2)
tbl = tibble::tibble(url = 'http://foo.bar')
class(tbl$url) = 'hyperlink'
wb_workbook() |> 
  wb_add_worksheet() |> 
  wb_add_data(x = as.data.frame(tbl)) |>
  wb_to_df(show_formula = TRUE)
#>                            url
#> 2 =HYPERLINK("http://foo.bar")

@JanMarvin JanMarvin added the Third party 📦 Using or impacting external library or software label Jan 16, 2024
JanMarvin added a commit that referenced this issue Jan 17, 2024
In a future version, this spaghetti code should be replaced by something more stable. The conversion to a data frame should be done as soon as possible, and this additional conversion should not be necessary at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Third party 📦 Using or impacting external library or software
Projects
None yet
Development

No branches or pull requests

2 participants