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

Add support for Proc/lambda on column_types #50

Closed
westonganger opened this issue Oct 8, 2022 · 2 comments
Closed

Add support for Proc/lambda on column_types #50

westonganger opened this issue Oct 8, 2022 · 2 comments

Comments

@westonganger
Copy link
Owner

westonganger commented Oct 8, 2022

It would be good to support Proc/lambda for column types

This could be supported as

.to_xlsx(
  column_types: [
    :string, 
    ->(cell_val){ cell_val.start_with?("http") ? :hyperlink : :string }, 
    :float,
  ]
)

We dont need to do anything additional for spreadsheet_columns because its already instance evaluated so you can already do things like

.to_xlsx(
  spreadsheet_columns: ->(){
    [
      "Foo", :foo, :string
      "Bar", :bar, (bar.start_with?("http") ? :hyperlink : :string)
      "Baz", :baz, :float
    ]
  }
)
@westonganger
Copy link
Owner Author

This is being implemented in #51 if you want to try this out

@westonganger
Copy link
Owner Author

This is now implemented in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant