The error you get does not mean that the rails did not find the xlsx format: it means that it compares the list of formats that you provide (i.e. just xlsx) and compared them with a set of formats, it thinks the browser is ready to accept and could not find matches.
If there seems to be only one format you want to display, you donβt need to use respond_to at all - just replace everything with
render xlsx: "create", template: "api/reports/create"
Rails gets what it thinks is an acceptable format from the extension on the url and Accept header. Format negotiation is usually done with an extension, than the Accept header - the binding (or publication) to /some/path.xlsx should set the format to xlsx. You can do this by including format: 'xlsx' in the parameters that you pass to the path helpers or as part of the hash of the routing parameters.
source share