Skip to content

Export Invalid .xlsx file in Api only mode #107

Closed
@NickBeukema

Description

@NickBeukema

I have created a base repo:
https://github.com/NickBeukema/axlsx_rails_testing

For both regular and api only mode, for both have done the following

  • Generate App and Lead model with properties Name and Occupation
  • Create LeadsController with index method, add resources :leads to routes file
  • Create views/leads/index.xlsx.axlsx file for rendering the .xlsx file

I visit the url and the api only version exports the file as 1 byte and cannot be opened, while the non api only version exports the excel file normally.

To reproduce the two repos, do the following:

  1. Clone and bundle
  2. rails db:migrate db:seed
  3. rails s
  4. Visit localhost:3000/leads.xlsx

I've also added a json responder to assure that the data is there and the respond_to function is working, so you can visit localhost:3000/leads.json to see the json data.

Do you know what dependencies I'm missing in the api only version? I've already included ActionController::MimeResponds to allow for respond_to usage. Any help would be great!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions