caxlsx / caxlsx_rails

A Rails plugin to provide templates for the axlsx gem
MIT License
735 stars 84 forks source link

Is there anyway to render xlsx package object without template? #150

Closed east2dd closed 3 years ago

straydogstudio commented 3 years ago

Sure. You can run the Caxlsx code directly in the controller, or in a model, or in some other location. Then take the final object and render it to a string and return it in the controller. Something like this in the end:

p = Axlsx::Package.new
//do stuff here to create your workbook
send_data p.to_stream.string, filename: "file_name.xlsx", type: Mime::XLSX, disposition: 'attachment'

You can also join the Slack channel for caxlsx and ask questions there. See the Readme for Caxlsx.

east2dd commented 3 years ago

Great I will try @straydogstudio