caxlsx_rails 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +97 -0
- data/Gemfile +53 -0
- data/Gemfile.lock +279 -0
- data/Gemfile.lock.4.2 +255 -0
- data/Gemfile.lock.5.1 +261 -0
- data/Gemfile.lock.5.2 +216 -0
- data/Guardfile +16 -0
- data/MIT-LICENSE +20 -0
- data/README.md +545 -0
- data/Rakefile +29 -0
- data/lib/axlsx_rails.rb +5 -0
- data/lib/axlsx_rails/action_controller.rb +68 -0
- data/lib/axlsx_rails/railtie.rb +16 -0
- data/lib/axlsx_rails/template_handler.rb +37 -0
- data/lib/axlsx_rails/version.rb +5 -0
- data/lib/caxlsx_rails.rb +3 -0
- data/lib/tasks/axlsx_rails_tasks.rake +4 -0
- data/spec/axlsx_builder_spec.rb +48 -0
- data/spec/axlsx_mailer_spec.rb +15 -0
- data/spec/axlsx_renderer_spec.rb +16 -0
- data/spec/axlsx_request_spec.rb +202 -0
- data/spec/ci.rb +15 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/home_controller.rb +54 -0
- data/spec/dummy/app/controllers/likes_controller.rb +18 -0
- data/spec/dummy/app/controllers/users_controller.rb +27 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/notifier.rb +14 -0
- data/spec/dummy/app/models/like.rb +3 -0
- data/spec/dummy/app/models/user.rb +10 -0
- data/spec/dummy/app/views/home/_cover_sheet.xlsx.axlsx +3 -0
- data/spec/dummy/app/views/home/index.html.erb +4 -0
- data/spec/dummy/app/views/home/index.xlsx.axlsx +8 -0
- data/spec/dummy/app/views/home/useheader.xlsx.axlsx +8 -0
- data/spec/dummy/app/views/home/withpartial.xlsx.axlsx +9 -0
- data/spec/dummy/app/views/layouts/application.html.erb +12 -0
- data/spec/dummy/app/views/likes/index.html.erb +17 -0
- data/spec/dummy/app/views/likes/index.xlsx.axlsx +7 -0
- data/spec/dummy/app/views/notifier/instructions.html.erb +14 -0
- data/spec/dummy/app/views/users/index.html.erb +23 -0
- data/spec/dummy/app/views/users/index.xlsx.axlsx +1 -0
- data/spec/dummy/app/views/users/respond_with.xlsx.axlsx +8 -0
- data/spec/dummy/app/views/users/send_instructions.xlsx.axlsx +5 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +70 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +11 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +39 -0
- data/spec/dummy/config/environments/production.rb +69 -0
- data/spec/dummy/config/environments/test.rb +40 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +8 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +14 -0
- data/spec/dummy/db/migrate/20120717192452_create_users.rb +12 -0
- data/spec/dummy/db/migrate/20121206210955_create_likes.rb +10 -0
- data/spec/dummy/db/schema.rb +32 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy_4/Rakefile +6 -0
- data/spec/dummy_4/app/assets/javascripts/application.js +13 -0
- data/spec/dummy_4/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy_4/app/controllers/application_controller.rb +5 -0
- data/spec/dummy_4/app/controllers/home_controller.rb +56 -0
- data/spec/dummy_4/app/controllers/likes_controller.rb +18 -0
- data/spec/dummy_4/app/controllers/users_controller.rb +27 -0
- data/spec/dummy_4/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_4/app/mailers/notifier.rb +14 -0
- data/spec/dummy_4/app/models/like.rb +3 -0
- data/spec/dummy_4/app/models/user.rb +10 -0
- data/spec/dummy_4/app/views/home/_cover_sheet.xlsx.axlsx +3 -0
- data/spec/dummy_4/app/views/home/index.html.erb +4 -0
- data/spec/dummy_4/app/views/home/index.xlsx.axlsx +8 -0
- data/spec/dummy_4/app/views/home/only_html.html.erb +1 -0
- data/spec/dummy_4/app/views/home/useheader.xlsx.axlsx +8 -0
- data/spec/dummy_4/app/views/home/withpartial.xlsx.axlsx +9 -0
- data/spec/dummy_4/app/views/layouts/application.html.erb +12 -0
- data/spec/dummy_4/app/views/layouts/users.html.erb +12 -0
- data/spec/dummy_4/app/views/likes/index.html.erb +17 -0
- data/spec/dummy_4/app/views/likes/index.xlsx.axlsx +7 -0
- data/spec/dummy_4/app/views/notifier/instructions.html.erb +14 -0
- data/spec/dummy_4/app/views/notifier/instructions.txt.erb +6 -0
- data/spec/dummy_4/app/views/users/export.xlsx.axlsx +8 -0
- data/spec/dummy_4/app/views/users/index.html.erb +23 -0
- data/spec/dummy_4/app/views/users/index.xlsx.axlsx +1 -0
- data/spec/dummy_4/app/views/users/noaction.xlsx.axlsx +1 -0
- data/spec/dummy_4/app/views/users/respond_with.xlsx.axlsx +8 -0
- data/spec/dummy_4/app/views/users/send_instructions.xlsx.axlsx +5 -0
- data/spec/dummy_4/bin/bundle +3 -0
- data/spec/dummy_4/bin/rails +4 -0
- data/spec/dummy_4/bin/rake +4 -0
- data/spec/dummy_4/config.ru +4 -0
- data/spec/dummy_4/config/application.rb +23 -0
- data/spec/dummy_4/config/boot.rb +5 -0
- data/spec/dummy_4/config/database.yml +25 -0
- data/spec/dummy_4/config/environment.rb +5 -0
- data/spec/dummy_4/config/environments/development.rb +37 -0
- data/spec/dummy_4/config/environments/production.rb +83 -0
- data/spec/dummy_4/config/environments/test.rb +40 -0
- data/spec/dummy_4/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_4/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy_4/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy_4/config/initializers/inflections.rb +16 -0
- data/spec/dummy_4/config/initializers/mime_types.rb +4 -0
- data/spec/dummy_4/config/initializers/secret_token.rb +2 -0
- data/spec/dummy_4/config/initializers/session_store.rb +3 -0
- data/spec/dummy_4/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_4/config/locales/en.yml +23 -0
- data/spec/dummy_4/config/routes.rb +17 -0
- data/spec/dummy_4/config/secrets.yml +22 -0
- data/spec/dummy_4/db/migrate/20120717192452_create_users.rb +12 -0
- data/spec/dummy_4/db/migrate/20121206210955_create_likes.rb +10 -0
- data/spec/dummy_4/db/schema.rb +32 -0
- data/spec/dummy_4/db/test.sqlite3 +0 -0
- data/spec/dummy_4/log/test.log +4652 -0
- data/spec/dummy_4/public/404.html +67 -0
- data/spec/dummy_4/public/422.html +67 -0
- data/spec/dummy_4/public/500.html +66 -0
- data/spec/dummy_4/public/favicon.ico +0 -0
- data/spec/dummy_5.0/Rakefile +6 -0
- data/spec/dummy_5.0/app/assets/javascripts/application.js +13 -0
- data/spec/dummy_5.0/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy_5.0/app/controllers/application_controller.rb +5 -0
- data/spec/dummy_5.0/app/controllers/home_controller.rb +56 -0
- data/spec/dummy_5.0/app/controllers/likes_controller.rb +18 -0
- data/spec/dummy_5.0/app/controllers/users_controller.rb +37 -0
- data/spec/dummy_5.0/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_5.0/app/mailers/notifier.rb +14 -0
- data/spec/dummy_5.0/app/models/like.rb +3 -0
- data/spec/dummy_5.0/app/models/user.rb +10 -0
- data/spec/dummy_5.0/app/views/home/_cover_sheet.xlsx.axlsx +3 -0
- data/spec/dummy_5.0/app/views/home/index.html.erb +4 -0
- data/spec/dummy_5.0/app/views/home/index.xlsx.axlsx +8 -0
- data/spec/dummy_5.0/app/views/home/only_html.html.erb +1 -0
- data/spec/dummy_5.0/app/views/home/useheader.xlsx.axlsx +8 -0
- data/spec/dummy_5.0/app/views/home/withpartial.xlsx.axlsx +9 -0
- data/spec/dummy_5.0/app/views/layouts/application.html.erb +12 -0
- data/spec/dummy_5.0/app/views/layouts/users.html.erb +12 -0
- data/spec/dummy_5.0/app/views/likes/index.html.erb +17 -0
- data/spec/dummy_5.0/app/views/likes/index.xlsx.axlsx +7 -0
- data/spec/dummy_5.0/app/views/notifier/instructions.html.erb +14 -0
- data/spec/dummy_5.0/app/views/notifier/instructions.txt.erb +6 -0
- data/spec/dummy_5.0/app/views/users/export.xlsx.axlsx +8 -0
- data/spec/dummy_5.0/app/views/users/index.html.erb +23 -0
- data/spec/dummy_5.0/app/views/users/index.xlsx.axlsx +1 -0
- data/spec/dummy_5.0/app/views/users/noaction.xlsx.axlsx +1 -0
- data/spec/dummy_5.0/app/views/users/respond_with.xlsx.axlsx +8 -0
- data/spec/dummy_5.0/app/views/users/send_instructions.xlsx.axlsx +5 -0
- data/spec/dummy_5.0/bin/bundle +3 -0
- data/spec/dummy_5.0/bin/rails +4 -0
- data/spec/dummy_5.0/bin/rake +4 -0
- data/spec/dummy_5.0/config.ru +4 -0
- data/spec/dummy_5.0/config/application.rb +23 -0
- data/spec/dummy_5.0/config/boot.rb +5 -0
- data/spec/dummy_5.0/config/database.yml +25 -0
- data/spec/dummy_5.0/config/environment.rb +5 -0
- data/spec/dummy_5.0/config/environments/development.rb +37 -0
- data/spec/dummy_5.0/config/environments/production.rb +83 -0
- data/spec/dummy_5.0/config/environments/test.rb +40 -0
- data/spec/dummy_5.0/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_5.0/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy_5.0/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy_5.0/config/initializers/inflections.rb +16 -0
- data/spec/dummy_5.0/config/initializers/mime_types.rb +4 -0
- data/spec/dummy_5.0/config/initializers/secret_token.rb +2 -0
- data/spec/dummy_5.0/config/initializers/session_store.rb +3 -0
- data/spec/dummy_5.0/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_5.0/config/locales/en.yml +23 -0
- data/spec/dummy_5.0/config/routes.rb +17 -0
- data/spec/dummy_5.0/config/secrets.yml +22 -0
- data/spec/dummy_5.0/db/migrate/20120717192452_create_users.rb +12 -0
- data/spec/dummy_5.0/db/migrate/20121206210955_create_likes.rb +10 -0
- data/spec/dummy_5.0/db/schema.rb +31 -0
- data/spec/dummy_5.0/public/404.html +67 -0
- data/spec/dummy_5.0/public/422.html +67 -0
- data/spec/dummy_5.0/public/500.html +66 -0
- data/spec/dummy_5.0/public/favicon.ico +0 -0
- data/spec/dummy_5.1/Rakefile +6 -0
- data/spec/dummy_5.1/app/assets/javascripts/application.js +13 -0
- data/spec/dummy_5.1/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy_5.1/app/controllers/application_controller.rb +5 -0
- data/spec/dummy_5.1/app/controllers/home_controller.rb +56 -0
- data/spec/dummy_5.1/app/controllers/likes_controller.rb +18 -0
- data/spec/dummy_5.1/app/controllers/users_controller.rb +37 -0
- data/spec/dummy_5.1/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_5.1/app/mailers/notifier.rb +14 -0
- data/spec/dummy_5.1/app/models/like.rb +3 -0
- data/spec/dummy_5.1/app/models/user.rb +10 -0
- data/spec/dummy_5.1/app/views/home/_cover_sheet.xlsx.axlsx +3 -0
- data/spec/dummy_5.1/app/views/home/index.html.erb +4 -0
- data/spec/dummy_5.1/app/views/home/index.xlsx.axlsx +8 -0
- data/spec/dummy_5.1/app/views/home/only_html.html.erb +1 -0
- data/spec/dummy_5.1/app/views/home/useheader.xlsx.axlsx +8 -0
- data/spec/dummy_5.1/app/views/home/withpartial.xlsx.axlsx +9 -0
- data/spec/dummy_5.1/app/views/layouts/application.html.erb +12 -0
- data/spec/dummy_5.1/app/views/layouts/users.html.erb +12 -0
- data/spec/dummy_5.1/app/views/likes/index.html.erb +17 -0
- data/spec/dummy_5.1/app/views/likes/index.xlsx.axlsx +7 -0
- data/spec/dummy_5.1/app/views/notifier/instructions.html.erb +14 -0
- data/spec/dummy_5.1/app/views/notifier/instructions.txt.erb +6 -0
- data/spec/dummy_5.1/app/views/users/export.xlsx.axlsx +8 -0
- data/spec/dummy_5.1/app/views/users/index.html.erb +23 -0
- data/spec/dummy_5.1/app/views/users/index.xlsx.axlsx +1 -0
- data/spec/dummy_5.1/app/views/users/noaction.xlsx.axlsx +1 -0
- data/spec/dummy_5.1/app/views/users/respond_with.xlsx.axlsx +8 -0
- data/spec/dummy_5.1/app/views/users/send_instructions.xlsx.axlsx +5 -0
- data/spec/dummy_5.1/bin/bundle +3 -0
- data/spec/dummy_5.1/bin/rails +4 -0
- data/spec/dummy_5.1/bin/rake +4 -0
- data/spec/dummy_5.1/config.ru +4 -0
- data/spec/dummy_5.1/config/application.rb +23 -0
- data/spec/dummy_5.1/config/boot.rb +5 -0
- data/spec/dummy_5.1/config/database.yml +25 -0
- data/spec/dummy_5.1/config/environment.rb +5 -0
- data/spec/dummy_5.1/config/environments/development.rb +37 -0
- data/spec/dummy_5.1/config/environments/production.rb +83 -0
- data/spec/dummy_5.1/config/environments/test.rb +40 -0
- data/spec/dummy_5.1/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_5.1/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy_5.1/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy_5.1/config/initializers/inflections.rb +16 -0
- data/spec/dummy_5.1/config/initializers/mime_types.rb +4 -0
- data/spec/dummy_5.1/config/initializers/secret_token.rb +2 -0
- data/spec/dummy_5.1/config/initializers/session_store.rb +3 -0
- data/spec/dummy_5.1/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_5.1/config/locales/en.yml +23 -0
- data/spec/dummy_5.1/config/routes.rb +17 -0
- data/spec/dummy_5.1/config/secrets.yml +22 -0
- data/spec/dummy_5.1/db/migrate/20120717192452_create_users.rb +12 -0
- data/spec/dummy_5.1/db/migrate/20121206210955_create_likes.rb +10 -0
- data/spec/dummy_5.1/db/schema.rb +31 -0
- data/spec/dummy_5.1/db/test.sqlite3 +0 -0
- data/spec/dummy_5.1/log/test.log +3645 -0
- data/spec/dummy_5.1/public/404.html +67 -0
- data/spec/dummy_5.1/public/422.html +67 -0
- data/spec/dummy_5.1/public/500.html +66 -0
- data/spec/dummy_5.1/public/favicon.ico +0 -0
- data/spec/dummy_5.2/Rakefile +6 -0
- data/spec/dummy_5.2/app/assets/javascripts/application.js +13 -0
- data/spec/dummy_5.2/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy_5.2/app/controllers/application_controller.rb +5 -0
- data/spec/dummy_5.2/app/controllers/home_controller.rb +56 -0
- data/spec/dummy_5.2/app/controllers/likes_controller.rb +18 -0
- data/spec/dummy_5.2/app/controllers/users_controller.rb +37 -0
- data/spec/dummy_5.2/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_5.2/app/mailers/notifier.rb +14 -0
- data/spec/dummy_5.2/app/models/like.rb +3 -0
- data/spec/dummy_5.2/app/models/user.rb +10 -0
- data/spec/dummy_5.2/app/views/home/_cover_sheet.xlsx.axlsx +3 -0
- data/spec/dummy_5.2/app/views/home/index.html.erb +4 -0
- data/spec/dummy_5.2/app/views/home/index.xlsx.axlsx +8 -0
- data/spec/dummy_5.2/app/views/home/only_html.html.erb +1 -0
- data/spec/dummy_5.2/app/views/home/useheader.xlsx.axlsx +8 -0
- data/spec/dummy_5.2/app/views/home/withpartial.xlsx.axlsx +9 -0
- data/spec/dummy_5.2/app/views/layouts/application.html.erb +12 -0
- data/spec/dummy_5.2/app/views/layouts/users.html.erb +12 -0
- data/spec/dummy_5.2/app/views/likes/index.html.erb +17 -0
- data/spec/dummy_5.2/app/views/likes/index.xlsx.axlsx +7 -0
- data/spec/dummy_5.2/app/views/notifier/instructions.html.erb +14 -0
- data/spec/dummy_5.2/app/views/notifier/instructions.txt.erb +6 -0
- data/spec/dummy_5.2/app/views/users/export.xlsx.axlsx +8 -0
- data/spec/dummy_5.2/app/views/users/index.html.erb +23 -0
- data/spec/dummy_5.2/app/views/users/index.xlsx.axlsx +1 -0
- data/spec/dummy_5.2/app/views/users/noaction.xlsx.axlsx +1 -0
- data/spec/dummy_5.2/app/views/users/respond_with.xlsx.axlsx +8 -0
- data/spec/dummy_5.2/app/views/users/send_instructions.xlsx.axlsx +5 -0
- data/spec/dummy_5.2/bin/bundle +3 -0
- data/spec/dummy_5.2/bin/rails +4 -0
- data/spec/dummy_5.2/bin/rake +4 -0
- data/spec/dummy_5.2/config.ru +4 -0
- data/spec/dummy_5.2/config/application.rb +23 -0
- data/spec/dummy_5.2/config/boot.rb +5 -0
- data/spec/dummy_5.2/config/database.yml +25 -0
- data/spec/dummy_5.2/config/environment.rb +5 -0
- data/spec/dummy_5.2/config/environments/development.rb +37 -0
- data/spec/dummy_5.2/config/environments/production.rb +83 -0
- data/spec/dummy_5.2/config/environments/test.rb +40 -0
- data/spec/dummy_5.2/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_5.2/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy_5.2/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy_5.2/config/initializers/inflections.rb +16 -0
- data/spec/dummy_5.2/config/initializers/mime_types.rb +4 -0
- data/spec/dummy_5.2/config/initializers/secret_token.rb +2 -0
- data/spec/dummy_5.2/config/initializers/session_store.rb +3 -0
- data/spec/dummy_5.2/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_5.2/config/locales/en.yml +23 -0
- data/spec/dummy_5.2/config/routes.rb +17 -0
- data/spec/dummy_5.2/config/secrets.yml +22 -0
- data/spec/dummy_5.2/db/migrate/20120717192452_create_users.rb +12 -0
- data/spec/dummy_5.2/db/migrate/20121206210955_create_likes.rb +10 -0
- data/spec/dummy_5.2/db/schema.rb +31 -0
- data/spec/dummy_5.2/db/test.sqlite3 +0 -0
- data/spec/dummy_5.2/log/test.log +3645 -0
- data/spec/dummy_5.2/public/404.html +67 -0
- data/spec/dummy_5.2/public/422.html +67 -0
- data/spec/dummy_5.2/public/500.html +66 -0
- data/spec/dummy_5.2/public/favicon.ico +0 -0
- data/spec/dummy_5/db/test.sqlite3 +0 -0
- data/spec/dummy_5/log/test.log +3645 -0
- data/spec/dummy_6.0/Rakefile +6 -0
- data/spec/dummy_6.0/app/assets/javascripts/application.js +13 -0
- data/spec/dummy_6.0/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy_6.0/app/controllers/application_controller.rb +5 -0
- data/spec/dummy_6.0/app/controllers/home_controller.rb +56 -0
- data/spec/dummy_6.0/app/controllers/likes_controller.rb +18 -0
- data/spec/dummy_6.0/app/controllers/users_controller.rb +37 -0
- data/spec/dummy_6.0/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_6.0/app/mailers/notifier.rb +14 -0
- data/spec/dummy_6.0/app/models/like.rb +3 -0
- data/spec/dummy_6.0/app/models/user.rb +10 -0
- data/spec/dummy_6.0/app/views/home/_cover_sheet.xlsx.axlsx +3 -0
- data/spec/dummy_6.0/app/views/home/index.html.erb +4 -0
- data/spec/dummy_6.0/app/views/home/index.xlsx.axlsx +8 -0
- data/spec/dummy_6.0/app/views/home/only_html.html.erb +1 -0
- data/spec/dummy_6.0/app/views/home/useheader.xlsx.axlsx +8 -0
- data/spec/dummy_6.0/app/views/home/withpartial.xlsx.axlsx +9 -0
- data/spec/dummy_6.0/app/views/layouts/application.html.erb +12 -0
- data/spec/dummy_6.0/app/views/layouts/users.html.erb +12 -0
- data/spec/dummy_6.0/app/views/likes/index.html.erb +17 -0
- data/spec/dummy_6.0/app/views/likes/index.xlsx.axlsx +7 -0
- data/spec/dummy_6.0/app/views/notifier/instructions.html.erb +14 -0
- data/spec/dummy_6.0/app/views/notifier/instructions.txt.erb +6 -0
- data/spec/dummy_6.0/app/views/users/export.xlsx.axlsx +8 -0
- data/spec/dummy_6.0/app/views/users/index.html.erb +23 -0
- data/spec/dummy_6.0/app/views/users/index.xlsx.axlsx +1 -0
- data/spec/dummy_6.0/app/views/users/noaction.xlsx.axlsx +1 -0
- data/spec/dummy_6.0/app/views/users/respond_with.xlsx.axlsx +8 -0
- data/spec/dummy_6.0/app/views/users/send_instructions.xlsx.axlsx +5 -0
- data/spec/dummy_6.0/bin/bundle +3 -0
- data/spec/dummy_6.0/bin/rails +4 -0
- data/spec/dummy_6.0/bin/rake +4 -0
- data/spec/dummy_6.0/config.ru +4 -0
- data/spec/dummy_6.0/config/application.rb +23 -0
- data/spec/dummy_6.0/config/boot.rb +5 -0
- data/spec/dummy_6.0/config/database.yml +25 -0
- data/spec/dummy_6.0/config/environment.rb +5 -0
- data/spec/dummy_6.0/config/environments/development.rb +37 -0
- data/spec/dummy_6.0/config/environments/production.rb +83 -0
- data/spec/dummy_6.0/config/environments/test.rb +40 -0
- data/spec/dummy_6.0/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_6.0/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy_6.0/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy_6.0/config/initializers/inflections.rb +16 -0
- data/spec/dummy_6.0/config/initializers/mime_types.rb +4 -0
- data/spec/dummy_6.0/config/initializers/secret_token.rb +2 -0
- data/spec/dummy_6.0/config/initializers/session_store.rb +3 -0
- data/spec/dummy_6.0/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_6.0/config/locales/en.yml +23 -0
- data/spec/dummy_6.0/config/routes.rb +17 -0
- data/spec/dummy_6.0/config/secrets.yml +22 -0
- data/spec/dummy_6.0/db/migrate/20120717192452_create_users.rb +12 -0
- data/spec/dummy_6.0/db/migrate/20121206210955_create_likes.rb +10 -0
- data/spec/dummy_6.0/db/schema.rb +31 -0
- data/spec/dummy_6.0/public/404.html +67 -0
- data/spec/dummy_6.0/public/422.html +67 -0
- data/spec/dummy_6.0/public/500.html +66 -0
- data/spec/dummy_6.0/public/favicon.ico +0 -0
- data/spec/reset_gems.sh +2 -0
- data/spec/spec_helper.rb +53 -0
- data/spec/test_3.1.sh +16 -0
- data/spec/test_3.2.sh +16 -0
- data/spec/test_4.0.sh +16 -0
- data/spec/test_4.1.sh +16 -0
- data/spec/test_4.2.sh +16 -0
- data/spec/test_5.0.sh +16 -0
- data/spec/test_5.1.sh +16 -0
- data/spec/test_5.2.sh +16 -0
- data/spec/test_6.0.sh +16 -0
- data/spec/test_all_rails.sh +8 -0
- data/spec/test_revert.sh +3 -0
- metadata +988 -0
data/Guardfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :version => 2 do
|
5
|
+
watch(%r{spec/.+_spec\.rb$})
|
6
|
+
watch('spec/spec_helper.rb') { "spec" }
|
7
|
+
watch(%r{spec/support/.+\.rb$}) { "spec" }
|
8
|
+
|
9
|
+
watch(%r{spec/dummy/app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
10
|
+
watch(%r{spec/dummy/app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
11
|
+
watch(%r{spec/dummy/app/controllers/.+\.rb$}) { ["spec/axlsx_renderer_spec.rb", "spec/axlsx_builder_spec.rb", "axlsx_request_spec.rb"] }
|
12
|
+
watch('lib/axlsx_rails/action_controller.rb') { ["spec/axlsx_renderer_spec.rb", "spec/axlsx_request_spec.rb"] }
|
13
|
+
watch('lib/axlsx_rails/template_handler.rb') { "spec/axlsx_builder_spec.rb" }
|
14
|
+
watch(%r{spec/dummy/app/mailers/.+\.rb$}) { "spec/axlsx_mailer_spec.rb" }
|
15
|
+
watch(%r{spec/dummy/app/views/.+\.erb}) { "spec/axlsx_request_spec.rb" }
|
16
|
+
end
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,545 @@
|
|
1
|
+
Notice: axlsx_rails renamed to caxlsx_rails
|
2
|
+
===================================================
|
3
|
+
This gem has been renamed to match other gems in the Axlsx community organization: http://github.com/caxlsx
|
4
|
+
|
5
|
+
Axlsx-Rails — Spreadsheet templates for Rails
|
6
|
+
===================================================
|
7
|
+
|
8
|
+
[![Build Status](https://secure.travis-ci.org/caxlsx/caxlsx_rails.svg?branch=master)](http://travis-ci.org/caxlsx/caxlsx_rails)
|
9
|
+
[![Gem
|
10
|
+
Version](https://badge.fury.io/rb/caxlsx_rails.svg)](http://badge.fury.io/rb/caxlsx_rails)
|
11
|
+
[![Coverage
|
12
|
+
Status](https://coveralls.io/repos/caxlsx/caxlsx_rails/badge.svg)](https://coveralls.io/r/caxlsx/caxlsx_rails)
|
13
|
+
|
14
|
+
![Total downloads](http://ruby-gem-downloads-badge.herokuapp.com/caxlsx_rails?type=total)
|
15
|
+
![Total downloads axlsx_rails](http://ruby-gem-downloads-badge.herokuapp.com/axlsx_rails?type=total)
|
16
|
+
![Downloads for 0.6.1 (latest)](http://ruby-gem-downloads-badge.herokuapp.com/caxlsx_rails/0.6.0?label=0.6.1)
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
In your Gemfile:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'caxlsx_rails'
|
24
|
+
```
|
25
|
+
|
26
|
+
See [previous installations](#previous-installations) if needed.
|
27
|
+
|
28
|
+
## Requirements
|
29
|
+
|
30
|
+
* Tested on Rails 4.2, 5.x and 6.0
|
31
|
+
* For Rails 3.1 or 3.2 use version 3.0
|
32
|
+
* **As of 0.5.0 requires Axlsx 2.0.1, but strongly suggests 2.1.0.pre, which requires rubyzip 1.1.0**
|
33
|
+
* As of Rails 4.1 you must use `render_to_string` to render a mail attachment.
|
34
|
+
|
35
|
+
## FYI
|
36
|
+
|
37
|
+
* This gem depends on [Axlsx](https://github.com/caxlsx/axlsx). See [the blog](http://axlsx.blog.randym.net/) or the [examples page](https://github.com/randym/axlsx/blob/master/examples/example.rb) for usage.
|
38
|
+
* Check out [axlsx_styler](https://github.com/sakovias/axlsx_styler) by [sakovias](https://github.com/sakovias) for easier styles and borders!
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
Axlsx-Rails provides a renderer and a template handler. It adds the `:xlsx` format and parses `.xlsx.axlsx` templates. This lets you take all the [Axlsx](https://github.com/caxlsx/axlsx) code out of your controller or model and place it inside the template, where view code belongs! **See [this blog post](http://axlsx.blog.randym.net/2012/08/excel-on-rails-like-pro-with-axlsxrails.html) for a more complete walkthrough.**
|
43
|
+
|
44
|
+
### Controller
|
45
|
+
|
46
|
+
To use Axlsx-Rails set your instance variables in your controller and configure the response if needed:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
class ButtonController < ApplicationController
|
50
|
+
def action_name
|
51
|
+
@buttons = Button.all
|
52
|
+
respond_to do |format|
|
53
|
+
format.xlsx
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
### Template
|
60
|
+
|
61
|
+
Create the template with the `.xlsx.axlsx` extension (`action_name.xlsx.axlsx` for example.) [**Watch out for typos!**](#troubleshooting) In the template, use xlsx_package variable to create your spreadsheet:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
wb = xlsx_package.workbook
|
65
|
+
wb.add_worksheet(name: "Buttons") do |sheet|
|
66
|
+
@buttons.each do |button|
|
67
|
+
sheet.add_row [button.name, button.category, button.price]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
This is where you place all your [Axlsx](https://github.com/caxlsx/axlsx) specific markup. Add worksheets, fill content, merge cells, add styles. See the [Axlsx examples](https://github.com/caxlsx/axlsx/tree/master/examples/example.rb) page to see what you can do.
|
73
|
+
|
74
|
+
Remember, like in `erb` templates, view helpers are available to use the `.xlsx.axlsx` template.
|
75
|
+
|
76
|
+
That's it. Call your action and your spreadsheet will be delivered.
|
77
|
+
|
78
|
+
### Rendering Options
|
79
|
+
|
80
|
+
You can call render in any of the following ways:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
# rendered, no disposition/filename header
|
84
|
+
render 'buttons'
|
85
|
+
# rendered from another controller, no disposition/filename header
|
86
|
+
render 'featured/latest'
|
87
|
+
# template and filename of 'buttons'
|
88
|
+
render xlsx: 'buttons'
|
89
|
+
# template from another controller, filename of 'latest_buttons'
|
90
|
+
render xlsx: 'latest_buttons', template: 'featured/latest'
|
91
|
+
```
|
92
|
+
|
93
|
+
### Disposition
|
94
|
+
|
95
|
+
To specify a disposition (such as `inline` so the spreadsheet is opened inside the browser), use the `disposition` option:
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
render xlsx: "buttons", disposition: 'inline'
|
99
|
+
```
|
100
|
+
|
101
|
+
If `render xlsx:` is called, the disposition defaults to `attachment`.
|
102
|
+
|
103
|
+
### File name
|
104
|
+
|
105
|
+
If Rails calls Axlsx through default channels (because you use `format.xlsx {}` for example) you must set the filename using the response header:
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
format.xlsx {
|
109
|
+
response.headers['Content-Disposition'] = 'attachment; filename="my_new_filename.xlsx"'
|
110
|
+
}
|
111
|
+
```
|
112
|
+
|
113
|
+
If you use `render xlsx:` the gem will try to guess the file name:
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
# filename of 'buttons'
|
117
|
+
render xlsx: 'buttons'
|
118
|
+
# filename of 'latest_buttons'
|
119
|
+
render xlsx: 'latest_buttons', template: 'featured/latest'
|
120
|
+
```
|
121
|
+
|
122
|
+
If that fails, pass the `:filename` parameter:
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
render xlsx: "action_or_template", filename: "my_new_filename.xlsx"
|
126
|
+
```
|
127
|
+
|
128
|
+
### Acts As Xlsx
|
129
|
+
|
130
|
+
If you use [acts_as_xlsx](https://github.com/caxlsx/acts_as_xlsx), configure the active record normally, but specify the package in the template:
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
User.to_xlsx package: xlsx_package, (other options)
|
134
|
+
```
|
135
|
+
|
136
|
+
**Note:** As of 4/1/2014 Acts As Xlsx is not compatible with Rails 4.1, and generates a warning on 4.0. You may use [my patched fork](https://github.com/caxlsx/acts_as_caxlsx) until it is remedied.
|
137
|
+
|
138
|
+
### Axlsx Package Options
|
139
|
+
|
140
|
+
Axlsx provides three options for initializing a spreadsheet:
|
141
|
+
|
142
|
+
- **:xlsx_author** (String) - The author of the document
|
143
|
+
- **:xlsx_created_at** (Time) - Timestamp in the document properties (defaults to current time)
|
144
|
+
- **:xlsx_use_shared_strings** (Boolean) - This is passed to the workbook to specify that shared strings should be used when serializing the package.
|
145
|
+
|
146
|
+
To pass these to the new package, pass them to `render :xlsx` _or_ pass them as local variables.
|
147
|
+
|
148
|
+
For example, to set the author name, pass the `:xlsx_author` parameter to `render :xlsx` _or_ as a local variable:
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
render xlsx: "index", xlsx_author: "Elmer Fudd"
|
152
|
+
render "index", locals: {xlsx_author: "Elmer Fudd"}
|
153
|
+
```
|
154
|
+
|
155
|
+
Other examples:
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
render xlsx: "index", xlsx_created_at: 3.days.ago
|
159
|
+
render "index", locals: {xlsx_use_shared_strings: true}
|
160
|
+
```
|
161
|
+
|
162
|
+
### Partials
|
163
|
+
|
164
|
+
Partials work as expected, but you must pass in relevant spreadsheet variables:
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
wb = xlsx_package.workbook
|
168
|
+
render :partial => 'cover_sheet', :locals => {:wb => wb}
|
169
|
+
wb.add_worksheet(name: "Content") do |sheet|
|
170
|
+
sheet.add_row ['Content']
|
171
|
+
end
|
172
|
+
```
|
173
|
+
|
174
|
+
With the partial simply using the passed variables:
|
175
|
+
|
176
|
+
```ruby
|
177
|
+
wb.add_worksheet(name: "Cover Sheet") do |sheet|
|
178
|
+
sheet.add_row ['Cover', 'Sheet']
|
179
|
+
end
|
180
|
+
```
|
181
|
+
|
182
|
+
### Mailers
|
183
|
+
|
184
|
+
To use an xlsx template to render a mail attachment, use the following syntax:
|
185
|
+
|
186
|
+
```ruby
|
187
|
+
class UserMailer < ActionMailer::Base
|
188
|
+
def export(users)
|
189
|
+
xlsx = render_to_string layout: false, handlers: [:axlsx], formats: [:xlsx], template: "users/export", locals: {users: users}
|
190
|
+
attachment = Base64.encode64(xlsx)
|
191
|
+
attachments["Users.xlsx"] = {mime_type: Mime[:xlsx], content: attachment, encoding: 'base64'}
|
192
|
+
# For rails 4 use Mime::XLSX
|
193
|
+
# attachments["Users.xlsx"] = {mime_type: Mime::XLSX, content: attachment, encoding: 'base64'}
|
194
|
+
# self.instance_variable_set(:@_lookup_context, nil) # If attachments are rendered as content, try this and open an issue
|
195
|
+
...
|
196
|
+
end
|
197
|
+
end
|
198
|
+
```
|
199
|
+
|
200
|
+
* If the route specifies or suggests the `:xlsx` format you do not need to specify `formats` or `handlers`.
|
201
|
+
* If the template (`users/export`) can refer to only one file (the xlsx.axlsx template), you do not need to specify `handlers`, provided the `formats` includes `:xlsx`.
|
202
|
+
* Specifying the encoding as 'base64' can avoid UTF-8 errors.
|
203
|
+
|
204
|
+
### Scripts
|
205
|
+
|
206
|
+
To generate a template within a script, you need to instantiate an ActionView context. Here are two gists showing how to perform this:
|
207
|
+
|
208
|
+
* [Using rails runner](https://gist.github.com/straydogstudio/323139591f2cc5d48fbc)
|
209
|
+
* [Without rails runner](https://gist.github.com/straydogstudio/dceb775ead81470cea70)
|
210
|
+
|
211
|
+
### Testing
|
212
|
+
|
213
|
+
There is no built-in way to test your resulting workbooks / templates. But here is a piece of code that may help you to find a way.
|
214
|
+
|
215
|
+
#### First, create a shared context
|
216
|
+
|
217
|
+
```ruby
|
218
|
+
RSpec.shared_context 'axlsx' do
|
219
|
+
|
220
|
+
# all xlsx specs describe must be normalized
|
221
|
+
# "folder/view_name.xlsx.axlsx"
|
222
|
+
# allow to infer the template path
|
223
|
+
template_name = description
|
224
|
+
|
225
|
+
let(:template_path) do
|
226
|
+
['app', 'views', template_name]
|
227
|
+
end
|
228
|
+
|
229
|
+
# This helper will be used in tests
|
230
|
+
def render_template(locals = {})
|
231
|
+
axlsx_binding = Kernel.binding
|
232
|
+
locals.each do |key, value|
|
233
|
+
axlsx_binding.local_variable_set key, value
|
234
|
+
end
|
235
|
+
# define a default workbook and a default sheet useful when testing partial in isolation
|
236
|
+
wb = Axlsx::Package.new.workbook
|
237
|
+
axlsx_binding.local_variable_set(:wb, wb)
|
238
|
+
axlsx_binding.local_variable_set(:sheet, wb.add_worksheet)
|
239
|
+
|
240
|
+
# mimics an ActionView::Template class, presenting a 'source' method
|
241
|
+
# to retrieve the content of the template
|
242
|
+
filename = Rails.root.join(*template_path).to_s
|
243
|
+
source = Struct.new(:source).new(File.read(filename))
|
244
|
+
axlsx_binding.eval(ActionView::Template::Handlers::AxlsxBuilder.new.call(source), filename)
|
245
|
+
axlsx_binding.local_variable_get(:wb)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
```
|
249
|
+
|
250
|
+
#### Include it in your spec files:
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
require 'spec_helper'
|
254
|
+
require 'helpers/axlsx_context'
|
255
|
+
|
256
|
+
describe 'shared/_total_request.xlsx.axlsx' do
|
257
|
+
include_context 'axlsx'
|
258
|
+
|
259
|
+
before :each do
|
260
|
+
# all the instance variables here are the one used in 'shared/_total_request.xlsx.axlsx'
|
261
|
+
@widget = mock_model(Widget, name: 'My widget')
|
262
|
+
@message_counts = Struct.new(:count_all, :positives, :negatives, :neutrals).new(42, 23, 15, 25)
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'has a title line mentioning the widget' do
|
266
|
+
wb = render_template
|
267
|
+
sheet = wb.sheet_by_name('Réf. Requête')
|
268
|
+
expect(sheet).to have_header_cells ['My widget : Messages de la requête']
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'exports the message counts' do
|
272
|
+
wb = render_template
|
273
|
+
sheet = wb.sheet_by_name('Réf. Requête')
|
274
|
+
expect(sheet).to have_cells(['Toutes tonalités', 'Tonalité positive', 'Tonalité négative', 'Tonalité neutre']).in_row(2)
|
275
|
+
expect(sheet).to have_cells([42, 23, 15, 25]).in_row(3)
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
279
|
+
```
|
280
|
+
|
281
|
+
#### Matchers used
|
282
|
+
|
283
|
+
```ruby
|
284
|
+
|
285
|
+
# encoding: UTF-8
|
286
|
+
|
287
|
+
require 'rspec/expectations'
|
288
|
+
|
289
|
+
module XslsMatchers
|
290
|
+
|
291
|
+
RSpec::Matchers.define :have_header_cells do |cell_values|
|
292
|
+
match do |worksheet|
|
293
|
+
worksheet.rows[0].cells.map(&:value) == cell_values
|
294
|
+
end
|
295
|
+
|
296
|
+
failure_message do |actual|
|
297
|
+
"Expected #{actual.rows[0].cells.map(&:value)} to be #{expected}"
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
RSpec::Matchers.define :have_cells do |expected|
|
302
|
+
match do |worksheet|
|
303
|
+
worksheet.rows[@index].cells.map(&:value) == expected
|
304
|
+
end
|
305
|
+
|
306
|
+
chain :in_row do |index|
|
307
|
+
@index = index
|
308
|
+
end
|
309
|
+
|
310
|
+
failure_message do |actual|
|
311
|
+
"Expected #{actual.rows[@index].cells.map(&:value)} to include #{expected} at row #{@index}."
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
```
|
317
|
+
|
318
|
+
|
319
|
+
## Troubleshooting
|
320
|
+
|
321
|
+
### Mispellings
|
322
|
+
|
323
|
+
**It is easy to get the spelling wrong in the extension name, the format.xlsx statement, or in a render call.** Here are some possibilities:
|
324
|
+
|
325
|
+
* If it says your template is missing, check that its extension is `.xlsx.axlsx`.
|
326
|
+
* If you get the error `uninitialized constant Mime::XSLX` you have used `format.xslx` instead of `format.xlsx`, or something similar.
|
327
|
+
|
328
|
+
### Mailer Attachments: No content, cannot read, Invalid Byte Sequence in UTF-8
|
329
|
+
|
330
|
+
If you are having problems with rendering a template and attaching it to a template, try a few options:
|
331
|
+
|
332
|
+
* Make sure the attachment template does not have the same name as the mailer.
|
333
|
+
* After you have rendered the template to string, and before you call the mailer, execute `self.instance_variable_set(:@_lookup_context, nil)`. If you must do this, please open an issue.
|
334
|
+
* If you get Invalid Byte Sequence in UTF-8, pass `encoding: 'base64'` with the attachment:
|
335
|
+
|
336
|
+
```ruby
|
337
|
+
class UserMailer < ActionMailer::Base
|
338
|
+
def export(users)
|
339
|
+
xlsx = render_to_string handlers: [:axlsx], formats: [:xlsx], template: "users/export", locals: {users: users}
|
340
|
+
attachments["Users.xlsx"] = {mime_type: Mime[:xlsx], content: xlsx, encoding: 'base64'}
|
341
|
+
# For Rails 4 use Mime::XLSX
|
342
|
+
# attachments["Users.xlsx"] = {mime_type: Mime::XLSX, content: xlsx, encoding: 'base64'}
|
343
|
+
# self.instance_variable_set(:@_lookup_context, nil) # If attachments are rendered as content, try this and open an issue
|
344
|
+
...
|
345
|
+
end
|
346
|
+
end
|
347
|
+
```
|
348
|
+
|
349
|
+
If you get these errors, please open an issue and share code so the bug can be isolated. Or comment on issue [#29](https://github.com/caxlsx/caxlsx_rails/issues/29) or [#25](https://github.com/caxlsx/caxlsx_rails/issues/25).
|
350
|
+
|
351
|
+
### Generated Files Can't Be Opened or Invalid Byte Sequence in UTF-8
|
352
|
+
|
353
|
+
Both these errors *appear* to be caused by Rails applying a layout to the template. Passing `layout: false` to `render :xlsx` should fix this issue. Version 0.5.0 attempts to fix this issue.
|
354
|
+
|
355
|
+
If you get this error, please open an issue and share code so the bug can be isolated.
|
356
|
+
|
357
|
+
### Rails 4.2 changes
|
358
|
+
|
359
|
+
Before Rails 4.2 you could call:
|
360
|
+
|
361
|
+
```ruby
|
362
|
+
render xlsx: "users/index"
|
363
|
+
```
|
364
|
+
|
365
|
+
And caxlsx_rails could adjust the paths and make sure the template was loaded from the right directory. This is no longer possible because the paths are cached between requests for a given controller. As a result, to display a template in another directory you must use the `:template` parameter (which is normal Rails behavior anyway):
|
366
|
+
|
367
|
+
```ruby
|
368
|
+
render xlsx: "index", template: "users/index"
|
369
|
+
```
|
370
|
+
|
371
|
+
If the request format matches you should be able to call:
|
372
|
+
|
373
|
+
```ruby
|
374
|
+
render "users/index"
|
375
|
+
```
|
376
|
+
|
377
|
+
This is a breaking change if you have the old syntax!
|
378
|
+
|
379
|
+
### Turbolinks
|
380
|
+
|
381
|
+
If you are using turbolinks, you may need to disable turbolinks when you link to your spreadsheet:
|
382
|
+
|
383
|
+
```ruby
|
384
|
+
# turbolinks 5:
|
385
|
+
link_to 'Download spreadsheet', path_to_sheet, data: {turbolinks: false}
|
386
|
+
```
|
387
|
+
|
388
|
+
### What to do
|
389
|
+
|
390
|
+
If you are having problems, try to isolate the issue. Use the console or a script to make sure your data is good. Then create the spreadsheet line by line without Axlsx-Rails to see if you are having Axlsx problems. If you can manually create the spreadsheet, create an issue and we will work it out.
|
391
|
+
|
392
|
+
## Previous Installations
|
393
|
+
|
394
|
+
In your Gemfile:
|
395
|
+
|
396
|
+
```ruby
|
397
|
+
gem 'rubyzip', '>= 1.2.1'
|
398
|
+
gem 'axlsx', git: 'https://github.com/randym/axlsx.git', ref: 'c8ac844'
|
399
|
+
gem 'axlsx_rails'
|
400
|
+
```
|
401
|
+
|
402
|
+
If `rubyzip 1.0.0` is needed:
|
403
|
+
|
404
|
+
```ruby
|
405
|
+
gem 'rubyzip', '= 1.0.0'
|
406
|
+
gem 'axlsx', '= 2.0.1'
|
407
|
+
gem 'axlsx_rails'
|
408
|
+
```
|
409
|
+
|
410
|
+
If `rubyzip >= 1.1.0` is needed:
|
411
|
+
|
412
|
+
```ruby
|
413
|
+
gem 'rubyzip', '~> 1.1.0'
|
414
|
+
gem 'axlsx', '2.1.0.pre'
|
415
|
+
gem 'axlsx_rails'
|
416
|
+
```
|
417
|
+
|
418
|
+
## Dependencies
|
419
|
+
|
420
|
+
- [Rails](https://github.com/rails/rails)
|
421
|
+
- [Axlsx](https://github.com/caxlsx/axlsx)
|
422
|
+
|
423
|
+
## Authors
|
424
|
+
|
425
|
+
* [Noel Peden](https://github.com/straydogstudio)
|
426
|
+
|
427
|
+
## Contributors
|
428
|
+
|
429
|
+
Many thanks to [contributors](https://github.com/caxlsx/caxlsx_rails/graphs/contributors):
|
430
|
+
|
431
|
+
* [randym](https://github.com/randym)
|
432
|
+
* [sugi](https://github.com/sugi)
|
433
|
+
* [envek](https://github.com/envek)
|
434
|
+
* [engwan](https://github.com/engwan)
|
435
|
+
* [maxd](https://github.com/maxd)
|
436
|
+
* [firien](https://github.com/firien)
|
437
|
+
* [kaluzny](https://github.com/kaluznyo)
|
438
|
+
* [sly7-7](https://github.com/sly7-7)
|
439
|
+
* [kodram](https://github.com/kodram)
|
440
|
+
* [JohnSmall](https://github.com/JohnSmall)
|
441
|
+
* [BenoitHiller](https://github.com/BenoitHiller)
|
442
|
+
|
443
|
+
## Donations
|
444
|
+
|
445
|
+
Say thanks for Axlsx-Rails by donating! It makes it easier for me to provide to open
|
446
|
+
source:
|
447
|
+
|
448
|
+
[![Click here to lend your support to: Axlsx-Rails!](http://www.pledgie.com/campaigns/27737.png?skin_name=chrome)](http://www.pledgie.com/campaigns/27737)
|
449
|
+
|
450
|
+
## Change log
|
451
|
+
|
452
|
+
**December 18, 2019**: 0.6.2 release
|
453
|
+
|
454
|
+
- Release under caxlsx_rails
|
455
|
+
|
456
|
+
**December 18, 2019**: 0.6.1 release
|
457
|
+
|
458
|
+
- Deprecate axlsx_rails name, release under caxlsx_rails
|
459
|
+
- Switch to using caxlsx 3.0 gem
|
460
|
+
|
461
|
+
**September 5, 2019**: 0.6.0 release
|
462
|
+
|
463
|
+
- Improved Rails 6.0 compatibility re MIME type
|
464
|
+
|
465
|
+
**May 1st, 2018**: 0.5.2 release
|
466
|
+
|
467
|
+
- Improved Rails 5 compatibility re MIME type
|
468
|
+
|
469
|
+
**March 29th, 2017**: 0.5.1 release
|
470
|
+
|
471
|
+
- Fix stack trace line numbers
|
472
|
+
- Thanks to [BenoitHiller](https://github.com/BenoitHiller)
|
473
|
+
|
474
|
+
**July 26st, 2016**: 0.5.0 release
|
475
|
+
|
476
|
+
- Support for Rails 5
|
477
|
+
- **Tested on on Rails 4.0, 4.1, 4.2, and 5.0**
|
478
|
+
- Bug fixes for unreadable files and UTF-8 errors
|
479
|
+
|
480
|
+
**July 13th, 2015**: 0.4.0 release
|
481
|
+
|
482
|
+
- Support for Rails 4.2
|
483
|
+
- **Removal of forced default_formats** (url format must match)
|
484
|
+
- **Tested only on Rails 4.1 and 4.2**
|
485
|
+
- **For Rails 3.2 or below, use 0.3.0**
|
486
|
+
|
487
|
+
**November 20th, 2014**: 0.3.0 release
|
488
|
+
|
489
|
+
- Support for Rails 4.2.beta4.
|
490
|
+
- **Removal of shorthand template syntax** (`render xlsx: 'another/directory'`)
|
491
|
+
|
492
|
+
**September 4, 2014**: 0.2.1 release
|
493
|
+
|
494
|
+
- Rails 4.2.beta1 no longer includes responder. This release checks for the existence of responder before configuring a default responder.
|
495
|
+
- Rails 4.2 testing, though not yet on Travis CI
|
496
|
+
- Author, created_at, and use_shared_strings parameters for Axlsx::Package.new
|
497
|
+
|
498
|
+
**April 9, 2014**: 0.2.0 release
|
499
|
+
|
500
|
+
- Require Axlsx 2.0.1, which requires rubyzip 1.0.0
|
501
|
+
- Better render handling and testing, which might break former usage
|
502
|
+
- Rails 4.1 testing
|
503
|
+
- Mailer example update (**use render_to_string not render**)
|
504
|
+
|
505
|
+
**October 11, 2013**
|
506
|
+
|
507
|
+
- Handle (and test) respond_to override
|
508
|
+
|
509
|
+
**October 4, 2013**
|
510
|
+
|
511
|
+
- Added coveralls
|
512
|
+
- Raised testing to axlsx 2.0.1, roo 1.12.2, and rubyzip 1.0.0
|
513
|
+
|
514
|
+
**July 25, 2013**
|
515
|
+
|
516
|
+
- Documentation improved
|
517
|
+
- Testing for generating partial in mailer
|
518
|
+
|
519
|
+
**January 18, 2013**: 0.1.4 release
|
520
|
+
|
521
|
+
- Now supports Rails 4 (thanks [Envek](https://github.com/Envek))
|
522
|
+
- If you call render :xlsx on a request without :xlsx format, it should force the :xlsx format. Works on Rails 3.2+.
|
523
|
+
|
524
|
+
**December 6, 2012**: 0.1.3 release
|
525
|
+
|
526
|
+
- Fix for absolute template paths
|
527
|
+
|
528
|
+
**July 25, 2012**: 0.1.2 release
|
529
|
+
|
530
|
+
- Partials tested
|
531
|
+
|
532
|
+
**July 19, 2012**: 0.1.1 release
|
533
|
+
|
534
|
+
- Travis-ci added (thanks [randym](https://github.com/randym))
|
535
|
+
- render statements and filename tests fixes (thanks [engwan](https://github.com/engwan))
|
536
|
+
|
537
|
+
**July 17, 2012**: 0.1.0 release
|
538
|
+
|
539
|
+
- Tests completed
|
540
|
+
- Acts_as_xlsx tested, example in docs
|
541
|
+
|
542
|
+
**July 12, 2012**: 0.0.1 release
|
543
|
+
|
544
|
+
- Initial posting.
|
545
|
+
- It works, but there are no tests! Bad programmer!
|