Open swiehr opened 6 years ago
@swiehr Thanks. I'll look into it.
@swiehr Have you had any luck on this? I've tried several ways and have not been able to reproduce it so far, although I have yet to chase it down Redmine context, which I will do next.
I would change your code to something more specific (I don't get the specified filename without specifying the template):
format.xlsx { render xlsx: "templatename.xlsx.axlsx", :filename => "my_class.xlsx" }
@swiehr How are you integrating axlsx_rails into Redmine?
@straydogstudio Tried your proposal with explicitly giving the template name, unfortunately to no avail. Regarding integration into Redmine I am not sure what information you need - I am using it in a Redmine plugin which provides own data structures and views, so basically there is nothing Redmine specific.
My Gemfile has this (enabled) group
group :axlsx do
gem 'acts_as_xlsx', github: 'swiehr/acts_as_xlsx'
gem 'axlsx', git: 'https://github.com/randym/axlsx.git', ref: 'a2259b0cb1000215491b5301a16f250098961a2c'
gem 'axlsx_rails', '= 0.5.2'
gem 'rubyzip', '= 1.2.0'
end
In my plugins init.rb I have
Rails.application.config.after_initialize do
plugin = Redmine::Plugin.find(:my_plugin)
begin
require 'acts_as_xlsx'
require 'axlsx_rails'
MY_FEATURE[:gem_axlsx] = true
rescue LoadError => e
Rails.logger.info "[INFO] XLSX export feature disabled - #{e.message}"
end
end
end
My models using axlsx have
acts_as_xlsx if MY_FEATURE[:gem_axlsx]
... although I think that is not relevant when using axlsx templates - checked and found that without that line I get exactly the same exception
@swiehr Thanks that will help. I meant what data are you exporting into a spreadsheet.
This error has cropped up here and there, and I have never been able to reproduce it. No one has been able to provide me with a repo. Given that your setup is based on Redmine, it will be easier for me to reproduce the error; then I can find the problem. Whatever information you can give me regarding your plugin will help. Is the plugin one of your repositories?
@straydogstudio Unfortunately the plugin is not (yet) open source (developing this at work so it's not me to decide about that) - from my perception it shouldn't be too difficult to reproduce this as I am simply exporting an index view (i.e. the complete table data) into an xlsx. Maybe I can write a small dummy plugin that would simply demonstrate this...
@swiehr I will do a straight export.
An example plugin would help. Or you could sketch out the relevant details in a gist.
@straydogstudio Check my small sample Redmine plugin https://github.com/swiehr/xlsx_export (after installation in Redmine will be available from the admin menu)
@swiehr Thank you very much. I should get a chance to look at this tomorrow night.
I also get "No template found" from axlsx_rails 0.5.2 or later (currently caxlsx_rails 0.6.2) Reverting to 0.5.1 finds the *.xlsx.axlsx tempate.
I also get "No template found" from axlsx_rails 0.5.2 or later (currently caxlsx_rails 0.6.2) Reverting to 0.5.1 finds the *.xlsx.axlsx tempate.
This resolved for me by explicitly adding caxlsx_rails in the container app's Gemfile, rather than pulling it in from another gem's gemspec as a runtime_dependency (even though Gemfile.lock is the same either way)
@alanq Thank you very much Alan. The automatic inclusion of Caxlsx has been brought up in another issue. I'll look into it.
I ran into the same problem. I solved the problem by specifying the formats.
render xlsx: 'hoge', template: 'template', formats: :xlsx
With version 0.5.2 I suddenly get missing template errors with code that works perfectly fine with 0.5.1
Catching the exception I see that the :axslx handler is missing but could not figure out why and how to fix this:
My controller code looks like this:
I am using the gem in different Redmine configurations:
Common is
any hints welcome...