Code Monkey home page Code Monkey logo

caxlsx_rails's Introduction

Caxlsx (Community Continued Version)

Test RuboCop Gem Version downloads

Notice: Community Axlsx Organization

To better maintain the Axlsx ecosystem, all related gems have been forked or moved to the following community organization:

https://github.com/caxlsx

Join the Caxlsx Slack channel

Synopsis

Axlsx is an Office Open XML Spreadsheet generator for the Ruby programming language. With Axlsx you can create Excel worksheets with charts, images (with links), automated and fixed column widths, customized styles, functions, tables, conditional formatting, print options, comments, merged cells, auto filters, file and stream serialization as well as full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification.

Screen 1

Feature List

  1. Author xlsx documents: Caxlsx is made to let you easily and quickly generate professional xlsx based reports that can be validated before serialization.

  2. Generate 3D Pie, Line, Scatter and Bar Charts: With Caxlsx chart generation and management is as easy as a few lines of code. You can build charts based off data in your worksheet or generate charts without any data in your sheet at all. Customize gridlines, label rotation and series colors as well.

  3. Custom Styles: With guaranteed document validity, you can style borders, alignment, fills, fonts, and number formats in a single line of code. Those styles can be applied to an entire row, or a single cell anywhere in your workbook.

  4. Automatic type support: Caxlsx will automatically determine the type of data you are generating. In this release Float, Integer, String, Date, Time and Boolean types are automatically identified and serialized to your spreadsheet.

  5. Automatic and fixed column widths: Caxlsx will automatically determine the appropriate width for your columns based on the content in the worksheet, or use any value you specify for the really funky stuff.

  6. Support for automatically formatted 1904 and 1900 epochs configurable in the workbook.

  7. Add jpg, gif and png images to worksheets with hyperlinks

  8. Reference cells in your worksheet with "A1" and "A1:D4" style references or from the workbook using "Sheet1!A3:B4" style references

  9. Cell level style overrides for default and customized style objects

  10. Support for formulas, merging, row and column outlining as well as cell level input data validation.

  11. Auto filtering tables with worksheet.auto_filter as well as support for Tables

  12. Export using shared strings or inline strings so we can inter-op with iWork Numbers (sans charts for now).

  13. Output to file or StringIO

  14. Support for page margins and print options

  15. Support for password and non password based sheet protection.

  16. First stage interoperability support for GoogleDocs, LibreOffice, and Numbers

  17. Support for defined names, which gives you repeated header rows for printing.

  18. Data labels for charts as well as series color customization.

  19. Support for sheet headers and footers

  20. Pivot Tables

  21. Page Breaks

Install

gem 'caxlsx'

Supported Ruby versions: Caxlsx supports Ruby 2.6 and newer.

Usage

Here's a teaser that kicks about 2% of what the gem can do.

Axlsx::Package.new do |p|
  p.workbook.add_worksheet(:name => "Pie Chart") do |sheet|
    sheet.add_row ["Simple Pie Chart"]
    %w(first second third).each { |label| sheet.add_row [label, rand(24)+1] }
    sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,5], :end_at => [10, 20], :title => "example 3: Pie Chart") do |chart|
      chart.add_series :data => sheet["B2:B4"], :labels => sheet["A2:A4"],  :colors => ['FF0000', '00FF00', '0000FF']
    end
  end
  p.serialize('simple.xlsx')
end

Please see the examples folder for further information on what you can do with this gem Chances are that it has already been implemented. If it hasn't, let's take a look at adding it in.

Documentation

Detailed documentation is available at:

https://www.rubydoc.info/gems/caxlsx/

Additional documentation is listed below:

⚠ Please do not create issues for questions regarding the usage of axlsx / caxlsx. Look through this README, the examples folder, and the FAQ, and also check questions tagged axlsx on Stack Overflow.

Feel free to add your question (including an answer!) to the FAQ if you think it is of general interest.

Plugins, Integrations, and Extensions

Currently the following additional gems are available:

  • acts_as_caxlsx
    • Provides simple ActiveRecord integration
  • caxlsx_rails
    • Provides a .axlsx renderer to Rails so you can move all your spreadsheet code from your controller into view files.
  • activeadmin-caxlsx
    • An Active Admin plugin that includes DSL to create downloadable reports.

Security

To prevent Formula Injection vulnerabilities, as of version 4.0, axlsx escapes all formulas by default. To permit formulas on a specific cell, please use:

cell.escape_formulas = false

You may set escape_formulas on the workbook, worksheet, row and/or cell level. Refer to examples/escape_formula.md for details.

To allow formulas globally by default (which was the behavior in axlsx 3.x and prior), you may set the following in an initializer:

Axlsx.escape_formulas = false

Known Software Interoperability Issues

As axslx implements the Office Open XML (ECMA-376 spec) much of the functionality is interoperable with other spreadsheet software. Below is a listing of some known issues.

  1. Libre Office

    • You must specify colors for your series. see examples/chart_colors.rb for an example.
    • You must use data in your sheet for charts. You cannot use hard coded values.
    • Chart axis and gridlines do not render. I have a feeling this is related to themes, which axlsx does not implement at this time.
  2. Google Docs

    • Images are known to not work with google docs
    • border colors do not work
  3. Apple Numbers

    • charts do not render
    • you must set 'use_shared_strings' to true. This is most conveniently done just before rendering by calling Package.use_shared_strings = true prior to serialization.
p = Axlsx::Package.new
p.workbook.add_worksheet(:name => "Basic Worksheet") do |sheet|
  sheet.add_row ["First Column", "Second", "Third"]
  sheet.add_row [1, 2, 3]
end
p.use_shared_strings = true
p.serialize('simple.xlsx')

Contributing

See CONTRIBUTING.md

Credits

Originally created by Randy Morgan - @randym

Forked in 2019, to enable the community to maintain the Axlsx ecosystem - https://github.com/caxlsx

Open source software is a community effort. None of this could have been done without the help of our Contributors.

caxlsx_rails's People

Contributors

aried3r avatar chrisgo-75 avatar correalucas avatar dependabot[bot] avatar donv avatar egallup02360 avatar engwan avatar envek avatar ericproulx avatar firien avatar inopinatus avatar kiskoza avatar kodram avatar leafac avatar liboul avatar lionellindt avatar maxd avatar nonusae avatar olleolleolle avatar petergoldstein avatar pwim avatar randym avatar sergey-alekseev avatar sly7-7 avatar straydogstudio avatar sugi avatar tagliala avatar tillsc avatar timdiggins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

caxlsx_rails's Issues

How to start new page?

I did not found documentation to explain how to i can jump to new page during generator.

Creating a document with large number of records

Hello is it possible to do some kind of batching? I have about 100k records, and my server crashes as soon as I try to export all of them. My template looks like this :

excel(xlsx_package) do |excel|
  excel.worksheet("Report") do |worksheet|
    worksheet.header "Reports", formatted_time(@timestamp) do
      worksheet.row
      worksheet.row style: excel.styles(:heading_centered), default_column_width: 18, height: 35 do |row|
        row.cell " A1"
        row.cell " A2"
        row.cell " A3"
        row.cell " Author"
        row.cell " Previous Value"
        row.cell " Current Value"
        row.cell " Timestamp"
      end
    end

    worksheet.body() do
      @reports.each do |bv|
        bv.formatted_changeset.each do |key, value|
          worksheet.row do |row|
            row.cell bv.deal.attribute_1
            row.cell bv.deal.attribute_2
            row.cell bv.deal.attribute_3
            row.cell bv.user.name
            row.cell value.first
            row.cell value.last
            row.cell bv.created_at.strftime('%b %e, %Y %I:%M %p %Z')
          end
        end
      end
    end
  end
end

I'm using rails 4, was thinking the use the find_each and basically write to a temp file in batches, and then serve the file from the filesystem to a user. Is this a possibility? Otherwise how do you solve the large record set issue?

Another Missing Template Issue

I'm trying to send Excel files as email attachments just as @gagalago tried in issue #12 . After trying to implement the listed solution, I'm still getting a 'missing template' error. Here's my code:

class Notifier < ActionMailer::Base
  default :from => '[email protected]'

  def instructions(report)
    @report = report
    attachments["report.xlsx"] = {mime_type: Mime::XLSX, content: save_xlsx report}
    mail :to => '[email protected]', :subject => 'Instructions'
  end

  private

  def save_xlsx(report)
    av = ActionView::Base.new
    av.view_paths = ActionController::Base.view_paths
    av.assign report: report
    av.render handlers: [:axlsx], template: '/reports/test_report'
  end
end

In the directory, views/reports, I have a template named test_report.xls.axlsx. However, I'm still getting the error:

WARN: Missing template reports/test_report with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip, :xlsx], :handlers=>[:axlsx]}. Searched in:

  • "/Users/me/development/repositories/myproject/app/views"

I know I'm doing something stupid, I just need another pair of eyes. Does anything jump out at anybody? Thanks.

mailer attachement

How can i use axls_rails within a mailer to have a attachement ?

in the mailer :

class SocialSecretariatMailer < ActionMailer::Base
  def export
   attachments["Nouvelles entrées.xlsx"] = render xlsx: "/administration/contracts/social_secretariat", disposition: "attachment", filename: "nouvelles entrées - CESAM Nature - #{Date.today.to_s}.xlsx"
...

the error

Missing template social_secretariat_mailer/export with {:locale=>[:fr], :formats=[:html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip, :xlsx], :handlers=>[:erb, :builder, :axlsx, :coffee, :haml, :prawn, :prawn_dsl]}. 
Searched in: (ActionView::MissingTemplate) * "/home/sigo/workspace/rcesam/app/views"

I feel that it is an error from the default rendered and not from the axls renderer.
Is it impossible to achieve this or I've made ​​a mistake ?

zipruby compatibility

Is there anyway to make this gem work with zipruby? I'm using this gem in a different project and love it, but I'm trying to integrate it into a large existing Rails app, but zipruby is used so I get conflict errors when trying to install rubyzip with zipruby. I'm using Spreadsheet gem in the app now and I'm really missing axlsx-rails.

Does anyone know of any workarounds to this?

Attachment doesn't show up on iPhone Mail app

I don't know where to post this exactly because I can't pinpoint if this is a problem with iOS or with this gem. Sorry about that.

The problem here is that if I use an xlsx template as mail attachment, I can perfectly see it on a browser or another app. However, if I use the default Mail app of iOS, I can tell that it detects that there's an attachment because of the paperclip icon. If I open the email though, it doesn't show the attachment. Any ideas? It would be a great help. Thanks a lot!

P.S. I'm using Rails 4.2 and I have tried both 0.3 and 0.2.1 versions of axlsx_rails.

Not finding template

I had a simple excel report working fine, and today all of a sudden it stopped working. When I attempt to open the file, I get a format not valid error. What I discovered is that the application was rendering the html content of my index.html.erb instead of my index.xlsx.axlsx. I tried renaming the view and explicitly calling the new name:

render xlsx: 'index_export'

I get an error that it cannot find the template.

Missing template passports/index_export, application/index_export with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :axlsx, :jbuilder]}.

Unable to run rails server with gem: "already initialized constant APP_PATH"

I added the axlsx_rails gem and installed in my project. If I run the rails server, I get the following error:

warning: already initialized constant APP_PATH
~/project/bin/rails:6: warning: previous definition of APP_PATH was here

I tried this with both rails 4.2.4 and 4.2.0. Here are the gem versions with using 4.2.0:

  • actionmailer (4.2.0)
    • actionpack (4.2.0)
    • actionview (4.2.0)
    • activejob (4.2.0)
    • activemodel (4.2.0)
    • activerecord (4.2.0)
    • activesupport (4.2.0)
    • addressable (2.3.8)
    • american_date (1.1.0)
    • arel (6.0.3)
    • autoparse (0.3.3)
    • autoprefixer-rails (6.0.2)
    • axlsx (1.3.6)
    • axlsx_rails (0.1.5)
    • bcrypt (3.1.10)
    • binding_of_caller (0.7.2)
    • bootstrap-sass (3.3.5.1)
    • bourbon (4.2.4)
    • builder (3.2.2)
    • bundler (1.10.6)
    • byebug (6.0.2)
    • capybara (2.5.0)
    • childprocess (0.5.6)
    • coffee-rails (4.1.0)
    • coffee-script (2.4.1)
    • coffee-script-source (1.9.1.1)
    • crack (0.4.2)
    • database_cleaner (1.5.0)
    • debug_inspector (0.0.2)
    • devise (3.5.2)
    • diff-lcs (1.2.5)
    • erubis (2.7.0)
    • execjs (2.6.0)
    • extlib (0.9.16)
    • factory_girl (4.5.0)
    • factory_girl_rails (4.5.0)
    • faraday (0.9.1)
    • ffi (1.9.10)
    • globalid (0.3.6)
    • google-api-client (0.8.6)
    • googleauth (0.4.2)
    • htmlentities (4.3.4)
    • i18n (0.7.0)
    • jasny-bootstrap-rails (3.1.3)
    • jbuilder (2.3.1)
    • jquery-rails (4.0.5)
    • json (1.8.3)
    • jwt (1.5.1)
    • launchy (2.4.3)
    • little-plugger (1.1.4)
    • logging (2.0.0)
    • loofah (2.0.3)
    • mail (2.6.3)
    • memoist (0.12.0)
    • mime-types (2.6.2)
    • mini_portile (0.6.2)
    • minitest (5.8.2)
    • mono_logger (1.1.0)
    • multi_json (1.11.2)
    • multipart-post (2.0.0)
    • nokogiri (1.6.6.2)
    • orm_adapter (0.5.0)
    • pg (0.18.3)
    • rack (1.6.4)
    • rack-protection (1.5.3)
    • rack-test (0.6.3)
    • rails (4.2.0)
    • rails-deprecated_sanitizer (1.0.3)
    • rails-dom-testing (1.0.7)
    • rails-html-sanitizer (1.0.2)
    • rails_apps_testing (0.3.12)
    • railties (4.2.0)
    • rake (10.4.2)
    • rdiscount (2.1.8)
    • rdoc (4.2.0)
    • redis (3.2.1)
    • redis-namespace (1.5.2)
    • responders (2.1.0)
    • resque (1.25.2)
    • resque-scheduler (4.0.0)
    • retriable (1.4.1)
    • rspec-core (3.3.2)
    • rspec-expectations (3.3.1)
    • rspec-mocks (3.3.2)
    • rspec-rails (3.3.0)
    • rspec-support (3.3.0)
    • rubyzip (1.1.7)
    • rufus-scheduler (3.1.4)
    • safe_yaml (1.0.4)
    • sass (3.4.18)
    • sass-rails (5.0.4)
    • sdoc (0.4.1)
    • selenium-webdriver (2.47.1)
    • signet (0.6.1)
    • sinatra (1.4.6)
    • singleton-rails (0.0.2.1 95d4972)
    • slim (3.0.6)
    • slim-rails (3.0.1)
    • spring (1.3.6)
    • sprockets (3.4.0)
    • sprockets-rails (2.3.3)
    • temple (0.7.6)
    • thor (0.19.1)
    • thread_safe (0.3.5)
    • tilt (2.0.1)
    • timecop (0.8.0)
    • tzinfo (1.2.2)
    • uglifier (2.7.2)
    • vcr (2.9.3)
    • vegas (0.1.11)
    • warden (1.2.3)
    • web-console (2.2.1)
    • webmock (1.21.0)
    • websocket (1.2.2)
    • will_paginate (3.0.7)
    • xpath (2.0.0)

0.4.0 generates file but can't be opened

I'm working with an extension of Spree 2.3. The method that generates the excel report is as follows:

def order_report
        export = !params[:q].nil?

        params[:q] ||= {}
        @show_only_completed = params[:q][:completed_at_not_null] == '1'
        params[:q][:s] ||= @show_only_completed ? 'completed_at desc' : 'created_at desc'

        # As date params are deleted if @show_only_completed, store
        # the original date so we can restore them into the params
        # after the search
        created_at_gt = params[:q][:created_at_gt]
        created_at_lt = params[:q][:created_at_lt]

        params[:q].delete(:inventory_units_shipment_id_null) if params[:q][:inventory_units_shipment_id_null] == "0"

        if !params[:q][:created_at_gt].blank?
          params[:q][:created_at_gt] = Time.zone.parse(params[:q][:created_at_gt]).beginning_of_day rescue ""
        end

        if !params[:q][:created_at_lt].blank?
          params[:q][:created_at_lt] = Time.zone.parse(params[:q][:created_at_lt]).end_of_day rescue ""
        end

        # Get the search parameters
        @search = Order.accessible_by(current_ability, :index).ransack(params[:q])

        # Restore dates
        params[:q][:created_at_gt] = created_at_gt
        params[:q][:created_at_lt] = created_at_lt
        render and return unless export

        @orders = @search.result(distinct: true) # TODO - make this a batch fetch

        # Put the orders into an Excel file
        render xlsx: "order_report", disposition: 'attachment', filename: 'order_report_' + Date.today.to_s + '.xlsx', xlsx_created_at: 0.days.ago

end

my template is called "order_report.xlsx.axlsx" and contains:

wb = xlsx_package.workbook

wb.add_worksheet(name: "Orders") do |sheet|

    titles =     [
        'Updated At',
        'Completed',
        'Order Number',
        'Name',
        'Address',
        'Phone',
        'Email',
        'Item',
        'url',
        'Quantity',
        'Order Total',
        'Status',
        'Shipping Status'
    ]

    sheet.add_row titles

    @orders.each do |order|
        first_row = true
        if order.line_items.any?
        order.line_items.each do |line_item|
            row = []

            row << (first_row ? order.updated_at : "")
            row << (first_row ? order.completed_at : "")
            row << (first_row ? order.number : "")
            if order.bill_address && first_row
                row << order.bill_address.full_name
                address_line = ""
                address_line << order.bill_address.address1 + " " if order.bill_address.address1?
                address_line << order.bill_address.address2 + " " if order.bill_address.address2?
                address_line << order.bill_address.city + " " if order.bill_address.city?
                address_line << order.bill_address.country.name + " " if order.bill_address.country_id?
                row << address_line
                row << (order.bill_address.phone? ? order.bill_address.phone : "")
            else
                row << ""
                row << ""
                row << ""
            end
            row << (first_row ? (order.email || "") : "")
            item = line_item.variant.name
            if line_item.product.individual_sale
                if line_item.material
                    item += " - " + line_item.material.name
                    item += " (" + line_item.material.options_text.gsub('&nbsp;', '') + ")" unless !line_item.material && line_item.material.option_values.empty?
                end
                if line_item.frame
                    item += " " + line_item.frame.name
                    item += " (" + line_item.frame.options_text.gsub('&nbsp;', '') + ")" unless line_item.frame.option_values.empty?
                end
                row << item 

                if line_item.product.photo_info
                    row << line_item.product.photo_info.image.url(:original)
                elsif (line_item.photo_src == 'bigstock') && !line_item.photo_key.blank?
                    if line_item.purchased_image
                        row << Bigstock::PurchasedImage.download_url(line_item.purchased_image.key)
                    else
                        row << "Bigstock image not purchased"
                    end
                elsif (line_item.photo_src == 'usrimg') && !line_item.photo_key.blank?
                    photo = UserPhoto.find_by_photo_hash line_item.photo_key
                    row << photo.photo.url(:original)
                else
                    row << (line_item.variant.images[0].attachment.url(:original)).to_s
                end
            else
                item += " (" + line_item.variant.options_text.gsub('&nbsp;', '') + ")" 
                row << item
                row << "" # cause there is no URL
            end

            row << line_item.quantity
            row << (first_row ? order.total.to_s : "")
            row << (first_row ? order.state.downcase.to_s : "")
            row << (first_row ? order.shipment_state.to_s : "")
            first_row = false
            sheet.add_row row
        end
        end
    end

end

The sheet generated using 0.3.0 using this exact code can be viewed at https://docs.google.com/a/grenadinetech.com/spreadsheets/d/17qV3gC23V-JR255_peZauy6WUBf1Ur5UJeUVD3tGPX8/edit?usp=sharing

I've had to version-lock the gem in order to continue developing the template on our extension. Any thoughts about what could have changed between versions to cause this error? Need any additional information?

:b does not work (Numbers)

the style 'bold' boolean (:b) does not work in Numbers? In Excel it works ok. Don't know if this a axlsx_rails issue or axlsx_styler issue (which I'm also using)? thnx.

undefined method `reopen' for "streamed":String

I'm using axlsx rails 0.1.5 with rvm, ruby-2.1.0 and rails 4.0.4,

I get the following exception in my view, and it seems to be an axlsx problem.
The line number in the error is invalid as the view file itself is only 25 lines long.

An ActionView::Template::Error occurred in competences#certificates_to_excel:

  undefined method `reopen' for "streamed":String
  app/views/cb/competences/certificates_to_excel.xlsx.axlsx:27:in `_app_views_cb_competences_certificates_to_excel_xlsx_axlsx___1718042271781105460_75871920'

When I grep the code, the only code where I find mentions of "reopen" or "streamed" are in rubyzip code and axlsx/axlsx_rails.

The problem is that I'm unable to duplicate this in my development environment. It only occurs in production, where the ruby and gem versions are the same.

I would like to use newer version of axlsx, but for some reason the gem always uses axlsx-1.3.6. How can I use the latest 2.0.1 version?

Invalid byte sequence in UTF-8 when generating spreadsheet

@straydogstudio
In my rails app, I'm trying to attach a generated xlsx file (basic) in a Sidekiq delayed mail. I'm getting the error: WARN: invalid byte sequence in UTF-8 every time I run the sending jobs.

mailer.rb

xlsx = (render_to_string handlers: [:axlsx], formats: [:xlsx],
    template: "report", layout: false)
attachments["#{subject}.xlsx"] = { mime_type: Mime::XLSX, content: xlsx }

report.xlsx.axlsx

wb.add_worksheet(:name => "Custom Report") do |sheet|
   sheet.add_row ["wrap", "me", "Up in Red"], :style => red_border
   sheet.add_row [1, 2, 3], :style => blue_border
end

Gem version 0.3.0, Rails 4.1.7, Ruby 2.2.0

Gemfile

...
gem 'sidekiq'
gem 'sidetiq'
gem 'rack-timeout'
gem 'axlsx_rails'

If I comment out the xlsx block, email sends fine.
Thanks for your help in advance 😄

wrong number of arguments (2 for 1)

Hi, I am following the basic tutorial. In my controller I have:

def index
@Collaborators = Collaborator.all
respond_to do |format|
format.html # index.html.erb
format.xlsx
end
end

And I get:

wrong number of arguments (2 for 1) from the template (index.xlsx.axlsx)

Any more info I can give you?

Render code in README

I think we should change

render "foobar", filename: "the_latest_foobar", disposition: 'inline'

to

render xlsx: "foobar", filename: "the_latest_foobar", disposition: 'inline'

The first one is equivalent to:

render action: "foobar", filename: "the_latest_foobar", disposition: 'inline'

and doesn't go through the xlsx renderer.

Is there a way to have the Template in external file?

First - thank you very much for this gem! We're using it as the reporting sub-system in a Rails app.

Is there any way to have the template be external - perhaps stored in S3? Then use a link to it (we would have a table of reports)?

This would allow us to create axslx (reports) without having to push the new code to Heroku.

show how to use controller variables in README

Maybe I'm stupid, but it took me a while to figure out that the .axlsx format was just ruby and that you could use controller variables right in the .axlsx file itself. For a while, I was trying to make it a index.xlsx.axlsx.erb file so that I could use erb. =P

Would be useful to have something in the README like

# ProductsController
def index
  @products = Product.all
  respond_to do |format|
    format.html
    format.xlsx
  end
end

# index.xlsx.axlsx
wb = xlsx_package.workbook
wb.add_worksheet(name: "Foobar") do |sheet|
  @products.each do |product|
    sheet.add_row product.title
  end
end

Issue with Dropdown values using Axlsx gem

I'm trying to populate a list of values in the dropdown of excel using axlsx gem in rails. It seems like all the values in the dropdown are being displayed in lowercase.

 wb = xlsx_package.workbook  
 wb.add_worksheet(name: "sample_data") do |sheet|

  sheet.add_data_validation("A2:A1000", {
    :type => :list,
    :formula1 => "Red Orange NavyBlue",
    :showDropDown => false,
    :showErrorMessage => true,
    :errorTitle => '',
    :error => 'Please use the dropdown selector to choose the value',
    :errorStyle => :stop,
    :showInputMessage => true,
    :prompt => 'Choose the value from the dropdown'}) 
  end

In the dropdown, the values are appearing as red,orange,navyblue.

Is there a way, by which I can display the data as it is without the conversion to lowercase?(Red,Orange,NavyBlue)

Please help me out to solve this issue.

format.xlsx change filename?

Hi,

Thank you for this great gem :) Question, using format.xlsx how would you change the filename?

Many thanks,

Excel can't open file because some content is unreadable

Trying to use this gem for the first time, I spent about 2 hours trying to solve the error:

Excel could not open payments.xlsx because some content is unreadable. Do you want to open and repair this workbook?

The problem was that I missed the documentation stating to use wb = xlsx_package.workbook instead of p = Axlsx::Package.new.

Can we add this to the Troubleshooting section of the README?

Download xlsx with remote form

Hi,

i'm scratching my head for couple of hours now how to download xlsx generated file using a remote form. I know this is not strictly related to the axlsx_rails gem, but i can't figure it out.

How can i generate xlsx inside format.js respond and download it?

render_to_string requires :formats

I am using Rails 4.1.1 and using render_to_string in a Mailer. I was getting ActionView::MissingTemplate errors unless I specified :format in my Mailer:

    xlsx = render_to_string template: "reports/daily_activity",
                            locals: { orders: orders, stadium: stadium },
                            handlers: [:axlsx],
                            formats: [:xlsx]

Some basic questions

Can some kind soul hopefully point me to an example out there showing a controller action, and corresponding template ?

I've been trying to work through the README but either get Missing template or unrecognized MIME::XLSX errors. I'm sure I'm doing something silly.

I'm using axlsx_rails 0.1.4 and xlsx 1.3.6.

Thanks !

Cannot start the server with gem axlsx or axlsx_rails

I cannot start the server after adding the gem "acts as xlsx" to my gemfile.

I have read other posts on this problem but still haven't got a clue what is going on. Most seem to have resolved the problem by removing the gem from the gemfile. If I remove the gem, I can start the server but I need it to do what I want to do. Also, I get the same message if I use the gem "axlsx" or "axlsx_rails", so I believe that something that is required in this gem is creating this issue.

The error message is

"bin/rails:6: warning: already initialized constant APP_PATH /home/ubuntu/workspace/horsestud_app/bin/rails:6: warning: previous definition of APP_PATH was here
Error: Command '-b' not recognized"
if I run "rake -D --trace
I get:
LoadError: cannot load such file -- zip/zip
/usr/local/rvm/gems/ruby-2.2.1/gems/axlsx-1.3.6/lib/axlsx.rb:26:in require' /usr/local/rvm/gems/ruby-2.2.1/gems/axlsx-1.3.6/lib/axlsx.rb:26:in<top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/gems/axlsx_rails-0.1.5/lib/axlsx_rails.rb:1:in require' /usr/local/rvm/gems/ruby-2.2.1/gems/axlsx_rails-0.1.5/lib/axlsx_rails.rb:1:in<top (required)>'
/usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:76:in require' /usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:76:inblock (2 levels) in require'
/usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:72:in each' /usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:72:inblock in require'
/usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:61:in each' /usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:61:inrequire'
/usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler.rb:134:in require' /home/ubuntu/workspace/horsestud_app/config/application.rb:10:in<top (required)>'
/home/ubuntu/workspace/horsestud_app/Rakefile:4:in require' /home/ubuntu/workspace/horsestud_app/Rakefile:4:in<top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/gems/rake-10.5.0/lib/rake/rake_module.rb:28:in load' /usr/local/rvm/gems/ruby-2.2.1/gems/rake-10.5.0/lib/rake/rake_module.rb:28:inload_rakefile'
/usr/local/rvm/gems/ruby-2.2.1/gems/rake-10.5.0/lib/rake/application.rb:689:in raw_load_rakefile' /usr/local/rvm/gems/ruby-2.2.1/gems/rake-10.5.0/lib/rake/application.rb:94:inblock in load_rakefile'
/usr/local/rvm/gems/ruby-2.2.1/gems/rake-10.5.0/lib/rake/application.rb:176:in standard_exception_handling' /usr/local/rvm/gems/ruby-2.2.1/gems/rake-10.5.0/lib/rake/application.rb:93:inload_rakefile'
/usr/local/rvm/gems/ruby-2.2.1/gems/rake-10.5.0/lib/rake/application.rb:77:in block in run' /usr/local/rvm/gems/ruby-2.2.1/gems/rake-10.5.0/lib/rake/application.rb:176:instandard_exception_handling'
/usr/local/rvm/gems/ruby-2.2.1/gems/rake-10.5.0/lib/rake/application.rb:75:in run' /usr/local/rvm/gems/ruby-2.2.1/gems/rake-10.5.0/bin/rake:33:in<top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/bin/rake:23:in load' /usr/local/rvm/gems/ruby-2.2.1/bin/rake:23:in

'
/usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in eval' /usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in'

I have tried it with the gem 'rubyzip', :require => 'zip/zip' in the gemfile, but this makes not difference. I have also tried to put the require axlsx, require axlsx_rails in various rails.rb, application.rb in my workspace for the application but this does not achieve anything.

I really will appreciate any help I can be given to resolve this.

Thanking you in advance,

Weird encoding rendering .xlsx.axlsx template

I have a worker (tried from mailer alos) that renders an .xlsx.axlsx template and writes it to a Tempfile. I'm using this in one worker and it works perfectly. In another place I'm trying to user it that uses almost the same exact code, but it doesn't render the xlsx properly, it just writes out a file with 0 bytes. If I do a puts in the terminal from render 'path/to/template.xlsx.axlsx it outputs stuff but it looks like some encoding is wrong. I can see hints of xml in the obfuscated output, but something is definitely wrong.

Here's the code

    xls = render template: 'admin/raw_salary_reports/show.xlsx.axlsx', layout: false

    file = Tempfile.new(['position-salary-report', '.xlsx'], 'tmp')

    file.write(xls)

And here's the show.xlsx.axlsx file

wb = xlsx_package.workbook

wb.add_worksheet(name: 'Position Salary Reports') do |sheet|
  sheet.add_row ['Asset Size', 'Number Receiving', '75th Percentile', 'Median', '25th Percentile', 'Average']
  sheet.add_row []
end

gem 'axlsx', '2.1.0.pre'
gem 'axlsx_rails'
rails 4.2.6

Doesn't work with rails 4.2

Thanks for your great gem!

I have a Rails 4.1 app with UUID PostgreSQL database and fixtures, and tests don't run unless in Rails 4.2. So I have a pressing need to upgrade (would happily stay in 4.1 for a while otherwise).

Application doesn't boot with latest axlsx_rails and rails 4.2 with following stacktrace:

/Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/axlsx_rails-0.2.0/lib/axlsx_rails/action_controller.rb:56:in `<top (required)>': cannot load such file -- action_controller/metal/responder (LoadError)
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta1/lib/active_support/dependencies.rb:248:in `require'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta1/lib/active_support/dependencies.rb:248:in `block in require'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta1/lib/active_support/dependencies.rb:233:in `load_dependency'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta1/lib/active_support/dependencies.rb:248:in `require'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/axlsx_rails-0.2.0/lib/axlsx_rails.rb:2:in `<top (required)>'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:76:in `require'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:72:in `each'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:72:in `block in require'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:61:in `each'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:61:in `require'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler.rb:132:in `require'
    from /Users/tute/Sites/agromentor/rails/config/application.rb:7:in `<top (required)>'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/application.rb:82:in `require'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/application.rb:82:in `preload'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/application.rb:140:in `serve'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/tute/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'

Thank you again for your work.

Generating xlsx from model

I am trying to get the spreadsheet after it is generated by axlsx into my model so I can zip it up with some other files. How would I go about doing this?

Edit: I know how to zip, I am just wondering how to generate the spreadsheet from my model.

invalid byte sequence in UTF-8 when generating spreadsheet in Mailer

Hey there, I'm trying to attach an xlsx spreadsheet to a Sidekiq delayed email (only difference is that it's in the background), and I'm getting a WARN: invalid byte sequence in UTF-8 that blows up the sending job. I've tried all manner of different encoding options for the output from render_to_string, but no dice. This happens even when using very basic . The spreadsheet renders fine from the console and from a controller action. The email sends fine with no attachments. The following code is exactly what I'm running, with some names switched out. Gem version 0.3.0, Rails 4.1.7, Ruby 2.2.0

report_mailer.rb

xlsx = (render_to_string handlers: [:axlsx], formats: [:xlsx],
              template: "report")
attachments["report.xlsx"] = { mime_type: Mime::XLSX, content: xlsx }

report.xlsx.axlsx

wb.add_worksheet(:name => "Custom Borders") do |sheet|
   sheet.add_row ["wrap", "me", "Up in Red"], :style => red_border
   sheet.add_row [1, 2, 3], :style => blue_border
end

Output from a pry session right after the render_to_string call

[6] pry(#)> xlsx
03:24:34 worker.1 | => "PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�c8k��\u0000\u0000\u0000A\u0002\u0000\u0000\v\u0000\u0000\u0000_rels/.rels���N�0\f��<E���nH\b�e� ��\u0010*\u000F`\u0012�����\u0013��=�\u0003bh\b\u000E;Z�������\u0012f�B�=G\u0003��\u0005E���q0�����a��>���^����j$f\u0003c)�F�lG\n�\eN\u0014��g\tX�(�Nh'\u001CHo��J�w\u0006\u001C3U�2P1����ezb��\n\u0003��%�O\u0015���t��9P,'\u001A\u007F\\�:8\u0003rpk���8���5iY��6�\n:,�\t_��CR<�/���^����h)\u0014\u001D�SF�\u001FF��\u0015v\u0017�PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!������\u0001\u0000\u0000\t\u0005\u0000\u0000\r\u0000\u0000\u0000xl/styles.xml�T�j�0\u0010}�W\b}@em�@\u0017�P\u0002�B\u0013\n�C_�kym��Hr���\u0019I�-CC��\u000F���s��Fc���R<uBx4)�\u001D�����\u0010w�����\u0019��\u007FZc\u0015���\u0017�\u0006+x��HIr(�;�x�qU�Q��;t6��\f\u001FV\b��g�0-\n����i\u0004�3<D)�4\u0018�\u007F\n�{\u0002�uG���E%Y�Wek�V\u0005�\t\u0000k�\u0004z���\u001F��\u0012���&���k���� \u0001 I\u0018���K�;]\u0000�r��\v�k��%~�\a�T\e-�E2B0��\a���3=����\vTt2�\u0011vWS�\u0010pR�!R�\u001E�+g�w���F\u001A����p]\u0017�I�\f������Z\u0012�U��p�\u0002��<���V�����\u0000�q\u0016R>\u0005�?����\u0016%N\u0018'��f+��^C��\u0012����On�\u0012d�7����}��\u0005�\u007F�]\u0015���\u001E|\u0018��8���u|�b\u0015y\a���V�z��(�]\f?\u0006\a�����`�L[\u0003�0�\u0001���'�\u0010%�F�|��y�\u0018��\a�������~�/�/�-�\u0015F���-S8P�\u0004v�����\u0006PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!���\u0001\t\r\u0001\u0000\u0000�\u0001\u0000\u0000\u0011\u0000\u0000\u0000docProps/core.xmlm��N� \u0010��>E��\u0005Z5\eB�\a��41�F����K,�\u0000n��K����l�e���\u00182|;�.9���7%�\u0019A\t\u0018�7��%z�w�\u0006m+.-���\u0017�[pA�Ob��L�\u0012�C�\fc/����\"ab��;-B,]�����\u0005�\u0013r�5\u0004�� �$L�bD'e#\u0017��q�,h$�\u000E4��1�(�g�\n�\u0016�v��\u0015\u001D�i\u007F\u0015���\u001C�Z�a\u0018����8?�\u001F�O��WSe|\u0010F\u0002�x#�t B�*1v~�xu�O\u000F\u001F/�I��\u001D�>'���c�CUN�]J��5)\u0018����sr]���ppP��*������]U7\u007FPK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!���O��\u0000\u0000\u0000�\u0000\u0000\u0000\u0010\u0000\u0000\u0000docProps/app.xml���\n�0\u0014Ew��do\u0013\u001DDJ�.�������\r��B�,���\b�;^��p�n��b��\u001Ca+��\u0012\u0005�!�pn�u8�'���\u0012)@d\a��\u007FL�X�C-e2\v�1U\u0019c&\u0013E?r�q�4M�@O��\u0001Y\u001E�:J�\u0018��-�W(>�z�\u007F����/��g�>��_���\u0000PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�u�\u0000��\u0000\u0000\u0000\n\u0001\u0000\u0000\u001A\u0000\u0000\u0000xl/_rels/workbook.xml.rels���\n�0\u0010��>E���*\"\"M{\u0011�W�\u000F\u0010�mZl~�F�oo���\a���|�T����A�'�$l�\u0012\u00049���\u0019\t���>@SW\u0017�U�\t\u001E��\"W\u001CK\u0018S\nGD�#Y��\u000F��3�hU�2\u001A\fJ��!���\u001E�'\u0003���S�P��i����\u0001�-��Y��0i:y}����1|SA�����;����O��\u0005PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�=�9�\u0015\u0001\u0000\u0000�\u0002\u0000\u0000\u0013\u0000\u0000\u0000[Content_Types].xml��=O�0\u0010�w~E�\u0015�\u000E\f\b�$\u001D�\u0018�C�\u0001��$V�%�[�\u007F���K��������9[�W���\u000E\u0012��\ev�+V�WA\e�7�s�V>�U[o�\u0011��V�\r\er�OB�\u001A�I�!��J\u0017�����\u0017Q�Q� ���A��3�\\�����\u0005:���x^�gt�d��(�i\n���\u0004Z�\u0002y\u0002{���D��\u0006V�NDY��*2q��48�)�A����b-S~��RB\a�N!��<?���;t�Q@���\b�Y�A�������\u0012��*$�^~|�9}�q�\u0002��\u0002���\u0018\u0013H�\u0003@v�/�3�����\u0010��v�+w���_\u001C�s{�\u0003PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�@*\u0014��\u0000\u0000\u0000)\u0001\u0000\u0000\u000F\u0000\u0000\u0000xl/workbook.xml�����0\fE��\u0015���\u00161#�j�\u0006!�C��\u0003B���&��\u0000��\u0013^b������z�\u0017\u0006uF\u0016O�@9-@al��x0��]O\u0016�l�\v�qOtTy:��>���Z�\u001E��)�\u0018s�#\u000E6��\u000FZFF��GLa�������\bwB��0��|�+jO\u0001c�C\u0018\a��W��(�r�e�l����\e�� \b��o��\u0011U�\u0001\r�\\u\t�V���4(�|\u0016�q��-�\\�Oz��\u000FPK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!��(�js\u0000\u0000\u0000�\u0000\u0000\u0000#\u0000\u0000\u0000xl/worksheets/_rels/sheet1.xml.relsU�K\u000E\u0002!\u0010\u0005�����i��1\u0006��\u001C��\a �\u0002q��&���R��W���I�xS�X���$APv�\u0011��p���\u0005\u0016�n��>\f\u000E��\u0018��\u001AB����.P�<�Jy,����\u0003��j��z�Y�3��\u0006\u0018�\u007FQs�\u0002PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!��v\u0015��\u0001\u0000\u0000\b\u0004\u0000\u0000\u0018\u0000\u0000\u0000xl/worksheets/sheet1.xml�SMo�0\f��W\u0018�/v\at\v�8=��: [��\u001F�n�M�Be���z��\u001F%;�\u0003l�n�����V��\e\u001D��u\nM*�\u0016����X(S���a�q)n��\u001E���\u0001(�t�RQ\u0013�7q��\u001A\u001A�\u0016���H������b�Z�E(jt�)I>��TF\f\u001Dn�����T9�a�5`hhbAK�e]�Z\u0017���V��\n\u001E����X�������VV�\u0001=����\u001E��@*J�\u001D�(^��1w,zR���\u001D��\u0014�\u001F,\u0012�\u0014H\u001AkI\u001E3�\fB1a����V\u0004���\f�w�����9�v\u0017�-?���\fZU���\u000EJ�H�\u0005\u00169�l7\u0002?;\r�\u0002�~����gI���V\u0015;�?�\u0005����q����;b��R��W\t_���������/Mf)�gi'��\v\\]\u0006=�����\"���\u0014�Is�$�6�\u0003�w�\u000Ex�gUP����\u0002~�=x�x�e�4��I��~�\u001D����?�Nko��\u000Eeqz;��V\u0019������ ��n����t���w4��\u0010s���,fuf�|u�,�K[)�b�����k\u0011���`\u001F�\b��W\u0012��U\"���I������{�Z�\f�m��D�}v�_���\aPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�c8k��\u0000\u0000\u0000A\u0002\u0000\u0000\v\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000��\u0000\u0000\u0000\u0000_rels/.relsPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!������\u0001\u0000\u0000\t\u0005\u0000\u0000\r\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000��\u0002\u0001\u0000\u0000xl/styles.xmlPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!���\u0001\t\r\u0001\u0000\u0000�\u0001\u0000\u0000\u0011\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000���\u0002\u0000\u0000docProps/core.xmlPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!���O��\u0000\u0000\u0000�\u0000\u0000\u0000\u0010\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000��1\u0004\u0000\u0000docProps/app.xmlPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�u�\u0000��\u0000\u0000\u0000\n\u0001\u0000\u0000\u001A\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000���\u0004\u0000\u0000xl/_rels/workbook.xml.relsPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�=�9�\u0015\u0001\u0000\u0000�\u0002\u0000\u0000\u0013\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000���\u0005\u0000\u0000[Content_Types].xmlPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�@*\u0014��\u0000\u0000\u0000)\u0001\u0000\u0000\u000F\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000��\u000E\a\u0000\u0000xl/workbook.xmlPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!��(�js\u0000\u0000\u0000�\u0000\u0000\u0000#\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000���\a\u0000\u0000xl/worksheets/_rels/sheet1.xml.relsPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!��v\u0015��\u0001\u0000\u0000\b\u0004\u0000\u0000\u0018\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000���\b\u0000\u0000xl/worksheets/sheet1.xmlPK\u0005\u0006\u0000\u0000\u0000\u0000\t\u0000\t\u0000N\u0002\u0000\u0000�\n\u0000\u0000\u0000\u0000"

Thanks in advance for your help.

Generating Cyrillic documents raises exception

I'm using respond_to and show.xlsx.axlsx view with Cyrillic text and get this error.

Error during failsafe response: incompatible character encodings: UTF-8 and ASCII-8BIT

/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/show_exceptions.rb:131:in block in log_error' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.1.12/lib/active_support/deprecation/reporting.rb:20:insilence'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/show_exceptions.rb:129:in log_error' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/show_exceptions.rb:64:inrender_exception'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/show_exceptions.rb:59:in call' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.12/lib/rails/rack/logger.rb:13:incall'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/methodoverride.rb:24:in call' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/runtime.rb:17:incall'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.1.12/lib/active_support/cache/strategy/local_cache.rb:72:in call' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/lock.rb:15:incall'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/static.rb:61:in call' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/static.rb:61:incall'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/airbrake-3.1.8/lib/airbrake/user_informer.rb:16:in _call' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/airbrake-3.1.8/lib/airbrake/user_informer.rb:12:incall'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.12/lib/rails/engine.rb:456:in call' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.12/lib/rails/application.rb:143:incall'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/content_length.rb:14:in call' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.12/lib/rails/rack/log_tailer.rb:14:incall'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:81:in block in pre_process' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:79:incatch'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:79:in pre_process' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:54:inprocess'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:39:in receive_data' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:inrun_machine'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in run' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/backends/base.rb:63:instart'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/thin-1.5.1/lib/thin/server.rb:159:in start' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/handler/thin.rb:13:inrun'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/server.rb:268:in start' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.12/lib/rails/commands/server.rb:70:instart'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.12/lib/rails/commands.rb:54:in block in <top (required)>' /home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.12/lib/rails/commands.rb:49:intap'
/home/valentin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/railties-3.1.12/lib/rails/commands.rb:49:in <top (required)>' script/rails:6:inrequire'
script/rails:6:in `

'

How to test the resulting workbook ?

I just tried to make a move from using axlsx only to axlsx+axlsx_rails. This was great until I wanted to test.
Previously, I manually created the axlsx package and the workbook in a kind of helper, used in a controller, then I used to test this helper in isolation.
I could not find a way to access the resulting workbook in a ActionView::TestCase after I callled the render helper.
Maybe I just missed something, otherwise how would do this kind of things ? Let me now if I can help 😄

Attachment shows as text in body of email

This is the email body:

Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;
 charset=UTF-8
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="Daily Status 2014-09-02.xlsx"
Content-ID: <[email protected]>

UEsDBBQAAAgIAACYn+tjOGvU2QAAAEECAAALAAAAX3JlbHMvLnJlbHOtksFO
wzAMhu88ReT7mm5ICKFluyCk3RAqD2ASt43axJEToLw9gQNiaAgOO1r2//3f
wdv9Emb1QpI9RwPrpgVF0bLzcTDw2N2trmG/2z7QjKVe5NGnrGokZgNjKelG
62xHCpgbThTrpmcJWOoog05oJxxIb9r2Sst3BhwzVYcyUDGwzPqVZXpinpoK
A9W9JfpPFfe9t3TL9jlQLCcaf1yAOjgDcnBr0L+4OLb3wjVpWejcNoEKOiz4
CV+l2kNSPOUvr83fXpjSubVoKRQduVNGlx9G+ugVdhfvUEsDBBQAAAgIAACY
n+vvyqPEyAEAAAkFAAANAAAAeGwvc3R5bGVzLnhtbKVU22rcMBB971cIfUBl....

This is my mailer:

class StatusMailer < ActionMailer::Base
    default to: Proc.new { ['[email protected]']}, from: "[email protected]"

    def daily_coding_status

        # execute sp
        status_results = DailyStatus.execute_procedure("get_coding_status")

        # cache date
        @date = Time.zone.today.to_s

        xlsx = render_to_string handlers: [:axlsx], formats: [:xlsx], template: "status_mailer/status", locals: { status_results: status_results }
        attachments["Daily Status #{@date}" + ".xlsx"] = { mime_type: Mime::XLSX, content: xlsx}
        mail(:subject => "#{@date}  Status Report")
    end
end

This is the template 'status.xlsx.axlsx':

# build excel file
wbook = xlsx_package.workbook
wbook.add_worksheet(:name => "Daily Status") do |sheet|
    sheet.add_row ["Parent Location RID", "Location RID", "Location Name", "Unique Tools", "Total Parts", "Total Coded", "Total Not Coded", "Total Questions", "Total Do Not Code",
          "Total Ready To Code", "Unique Parts", "Unique Coded", "Unique Not Coded", "Unique Questions", "Unique Do Not Code", "Unique Ready To Code", "Percent Coded",
          "1 Day Difference", "7 Day Difference", "30 Day Difference"]

    status_results.each do |result|

    data_row = [result['parent_location_rid'], result['location_rid'], result['location_name'], result['unique_tools'], result['total_parts'], result['total_coded'], result['total_not_coded'],
                result['total_questions'], result['total_do_not_code'], result['total_ready_to_code'], result['unique_parts'], result['unique_coded'], result['unique_not_coded'], result['unique_questions'],
                result['unique_do_not_code'], result['unique_ready_to_code'], result['percent_coded'], result['one_day_difference'], result['seven_day_difference'], result['thirty_day_difference']]

      #add the row to the sheet
      sheet.add_row data_row, :types => [:string, :string, :string, :string, :string, :string, :string, :string, :string, :string, :string, :string, :string, :string, :string, :string, :string, :string, :string, :string]
    end
end

I can't see what I'm doing incorrectly.

axlsx file is not display anything which is string in 'Number software' of mac

I generate XLSX file and it's generate proper and open in windows MS Excel and its open perfect.

But when i open in 'Number software' of mac then it not display string value.

I try to assign data type like this : -

sheet.add_row [col_1, col_2, col_3, col_4, col_5], :types => [:string, :string, :string, :integer, :string]

but it display blank for sting and number type display properly.

Even if i define or not define any type then also nothing display in mac "Number software".

Missing Template error in production

I, [2016-09-08T17:25:44.073936 #41694]  INFO -- : Started GET "/admin/tablets_list" for 127.0.0.1 at 2016-09-08 17:25:44 +0530
I, [2016-09-08T17:25:44.107349 #41694]  INFO -- : Processing by Admin::CabinetsController#tablets_list as HTML
I, [2016-09-08T17:25:44.199807 #41694]  INFO -- :   Rendered admin/cabinets/tablets_list.html.erb within layouts/admin/application (63.1ms)
I, [2016-09-08T17:25:44.202837 #41694]  INFO -- :   Rendered shared/_flash_notifier.html.erb (0.6ms)
I, [2016-09-08T17:25:44.203983 #41694]  INFO -- : Completed 200 OK in 97ms (Views: 64.0ms | ActiveRecord: 10.0ms)
I, [2016-09-08T17:25:47.090020 #41694]  INFO -- : Started GET "/download_excel.xlsx" for 127.0.0.1 at 2016-09-08 17:25:47 +0530
I, [2016-09-08T17:25:47.091346 #41694]  INFO -- : Processing by Admin::CabinetsController#download_excel as XLSX
I, [2016-09-08T17:25:47.099323 #41694]  INFO -- : Completed 500 Internal Server Error in 8ms (ActiveRecord: 0.2ms)
F, [2016-09-08T17:25:47.100854 #41694] FATAL -- :
ActionView::MissingTemplate (Missing template admin/cabinets/download_excel, admin/base/download_excel, application/download_excel with {:locale=>[:en], :formats=>[:xlsx], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
  * "/Users/pulkit/dev/dev-scotta-smartcabinets/app/views"
  * "/Users/pulkit/.rvm/gems/ruby-2.2.1/gems/devise-3.4.1/app/views"
):
  app/controllers/admin/cabinets_controller.rb:12:in `block (2 levels) in download_excel'
  app/controllers/admin/cabinets_controller.rb:11:in `download_excel'


Controller action

def download_excel
  @cabinets = Cabinet.all
  respond_to do |format|
    format.xlsx {render xlsx: 'download_excel',filename: "smart_cab.xlsx"}
  end
end

In development its working fine without any error but in production it's giving me the Template missing error, please help.

Issues with rails server

I run into issues with rails server because of axlsx gem
This is the error:
warning: already initialized constant APP_PATH.

I couldn't find a solution to it so i had to switch gems as i needed to make some new changes to the app.

Though I'll love to use this gem in a later app.

Add styles via function call

We have a big spreadsheet generator and want to clean up the code a bit. Here is a shortened example:

p.workbook.styles do |s|
  red_bold_light_yellow_all_borders           = sheet.add_style fg_color: "FF0000", b: true, bg_color: "FFFF99", border: {style: :thin, color: "000000"}
  bold_light_yellow_all_borders_right_aligned = sheet.add_style                     b: true, bg_color: "FFFF99", border: {style: :thin, color: "000000"}                                                                                  , alignment: {horizontal: :right}

  p.workbook.add_worksheet(name: sheet_names(pool)[0]) do |sheet|
    sheet.add_row ["Intern", "Datum"], style: [red_bold_light_yellow_all_borders, bold_light_yellow_all_borders_right_aligned]
  end
end

The goal is to replace style generations with one function call like this:

p.workbook.styles do |s|
  generate_styles(s)

  p.workbook.add_worksheet(name: sheet_names(pool)[0]) do |sheet|
    sheet.add_row ["Intern", "Datum"], style: [red_bold_light_yellow_all_borders, bold_light_yellow_all_borders_right_aligned]
  end
end

def generate_styles(sheet)
  red_bold_light_yellow_all_borders           = sheet.add_style fg_color: "FF0000", b: true, bg_color: "FFFF99", border: {style: :thin, color: "000000"}
  bold_light_yellow_all_borders_right_aligned = sheet.add_style                     b: true, bg_color: "FFFF99", border: {style: :thin, color: "000000"}                                                                                  
end

We get a syntax error on generate_styles because of the special syntax of this gem (I suppose).

Do you have an idea how to solve it? Thanks in advance!

xlsx file is not rendering non-numeric characters

Hey,

So I'm working on setting up axlsx_rails in my rails app and am running into a consistent issue where the downloaded xlsx does not display any non-numeric characters. It also does not print any cells that contain a non-numeric character (i.e. "1p") would be a blank cell.

this is the file in the axlsx file:

wb = xlsx_package.workbook
wb.add_worksheet(name: "classes") do |sheet|
  @student.classes.each do |class|
    sheet.add_row [class.name, "1"]
  end
  sheet.add_row ["p", "2", "e", "3"]
end

The controller code is

class App::Company::ReportsController < ApplicationController
  include Concerns::UserRequirements
  include Concerns::SchoolRequirements

   skip_before_action :verify_authenticity_token
   layout :false

  def holders
    @student = Student.find(params[:id])
    render xlsx: "holders", template: "app/company/reports/holders.xlsx"

  end
end

Does anyone know what may be causing this?

Maintaining separate HTML and XLS view templates

@straydogstudio, you solution of having XLS view looks quite elegant as it perfectly fits into MVC paradigm. However I have a question about having two different templates for HTML and XLS views. Is there a solution in Rails to keep them in sync? So let's say to have a top level template that drives both HTML and XLS templates for a controller. In this case you make change in one place and reduce maintenance effort.

render :layout => false ?

Under Rails 3.2.10, I am having to specify :layout => false in my render line, otherwise I end up with HTML in the output file. Is that expected? Do layouts even make sense for axlsx?

Missing Template error in Production only

I am using version 0.5.0 on Rails 5 and everything works great on development. I am using the example code provided in the docs and the xlsx file is perfect.

When i try in production however i get a

No template found for Admin::ReportsController#create, rendering head :no_content

This error also fails silently, i click on the create report button and nothing happens.

I then tried to use a more explicit render version with:

  def create
    render xlsx: 'create'
  end

And i get this error:

Missing template admin/reports/create, admin/create, application/create with {:locale=>[:"en-GB", :en], :formats=>[:xlsx], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}

It looks like the handler :xlsx is not registered and Rails can't find the template. However, in development everything works just great??

subscript and superscript

how can i write some subscript text in the header of a table? html tags sub and /sub> doesn't work.

render options issues

the 'render' action is working, however I've encountered the following issues:

  1. while specifying the template to render, I had to explicit name the .xlsx.axlsx file extension, otherwise I got an error "template not found". In the instructions the file extension is not named?
  2. I can't get the option > disposition: "inline" < to work; using this option the file is still downloaded?

my action look like this now:

def report
render xlsx: "scanreport", template: "scans/report.xlsx.axlsx", disposition: 'inline'
end

thnx in advance!

Rails 5 support

As Rails 5.0 is out now, can we get compatibility release in rubygems, please?

Excel 2016 unable to open generated document

I have been experiencing issues with opening generated documents with Excel 2016. Excel presents the following message:
2c127a76-27e4-11e6-8391-eb113ec8df7c
If I "Open and Repair" I'm offered the chance to see the log file of what was removed, and the repaired sheet is opened. It's not very helpful...

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>Repair Result to generated_report_30.xml</logFileName><summary>Errors were detected in file '/Users/martinpeck/Library/Containers/it.bloop.airmail2/Data/Library/Application Support/Airmail/General/Tmp/generated_report_3.xlsx'</summary><additionalInfo><info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info></additionalInfo></recoveryLog>

It appears OSX Numbers has an issue with fonts:
0868f612-27e5-11e6-8ea9-6ff90fa148c4

OSX OpenOffice opens it fine without issue.

The report is generated via a rake task. Here is the code that I am generating the doc:

view_assigns = {users: User.all, referrals: ReferralTracker.all, reporting_regions: ReportingRegion.all}
av = ActionView::Base.new(ActionController::Base.view_paths, view_assigns)

content = av.render template: 'dashboard/generate_report.xlsx.axlsx'

report = File.open("./tmp/codeclub-numbers-report-#{Date.today}.xlsx","w+b") {|f| f.puts content }

The template is fairly large so here is the main call:

wb = xlsx_package.workbook
wb.styles do |s|

header_title =  s.add_style  :bg_color => "ff9900", :fg_color => "FF", :sz => 11, :alignment => { :horizontal=> :left }
date_header =  s.add_style :sz => 18, :alignment => { :horizontal=> :left }
section =  s.add_style :sz => 10, :alignment => { :horizontal=> :left }


wb.add_worksheet(name: "Reporting Sheet") do |sheet|
    sheet.add_row ["Report ran for #{1.month.ago.beginning_of_month.strftime("%B")}"], :style => [date_header]
.....
....
    end
end

Anyone have any ideas what might be causing this?

Template is missing

When rendering a template, it always looks for the controller name plus the parameter one pass to it.

Is there a way to specify the absolute path from app/views?

I'm using activeadmin and I have a page registered:

ActiveAdmin.register_page 'my_page' do

end

In this case the controller is my_page. When I render :xlsx => 'reports/my_report' it looks for a template called my_page/reports/my_report.

I want it to be just reports/my_report. Is this possible?

render generate an empty/corrupted XML file when using xlsx template

Hello,

I'm trying to simply build a very basic xlsx document and send it by e-mail as attachment.

I read your advice and also the similar issues that other users had, but can't figure out what I'm doing wrong after 2 days of search and tests.

I also test to put the template code into the mailer and serialize the package to my harddrive before to attach it as file in my email, and it works : the XML file is complete and clean. So I guess the problems is somehow linked to the "template feature"...?

Here it is my template : app/views/projects/reports/horizon_lists.xlsx.axlsx

# encoding: UTF-8
# Template report : this is a copy from examples https://github.com/randym/axlsx/blob/master/examples/example.rb
package = Axlsx::Package.new
workbook = package.workbook

workbook.add_worksheet(:name => "Basic Worksheet") do |sheet|
    sheet.add_row ["First Column", "Second", "Third"]
    sheet.add_row [1, 2, 3]
    # by the way this is not working. Space are not preserved...
    sheet.add_row ['     preserving whitespace']
end

Here it is my mailer : app/mailers/rapport_mailer.rb

# encoding: UTF-8
class RapportMailer < ActionMailer::Base
  default from: "[email protected]"
  def rapport_listes_horizons(utilisateur, hash_pm, liste_annees, nom_fichier)

    @hash_pm = hash_pm
    @liste_annees = liste_annees

    # I also tried with render_to_string and the resutl is the same
    xlsx = render :handlers => [:axlsx], :template => 'projects/reports/horizon_lists', :layout=> false
    attachments[nom_fichier] = {:mime_type => Mime::XLSX, :content => xlsx }

    mail(:to => utilisateur.email, :body => '', :subject => "Rapport des listes d'horizons (message automatique)")
  end
end 

Here it is my controller : app/controllers/projects/reports_controller.rb

# encoding: UTF-8
require Rails.root.to_s + '/lib/opf_modules/opf_outils_controlleurs.rb'

class Projects::ReportsController < ApplicationController

  # Empêche l'accès aux vues de ce contrôleur tant que l'utilisateur n'est pas authentifié (avec Devise)
  before_filter :authenticate_admin_utilisateur!

  # Règlemente l'usage de la ressource sur toutes les actions conformément à la configuration de declarative_authorization
  filter_access_to :all

  # https://github.com/straydogstudio/axlsx_rails
  respond_to :html, :xlsx

  include OutilsControlleurs

  def horizon_lists
    # messages d'erreurs
    messages = {}
    @tableau_annees = []
    @hash_pm = {}

    ...

    if messages.has_key?('alert') or messages.has_key?('error') then
      # Récupérer les messages d'erreur
      afficher_maintenant(messages)
      render 'errors'
    else
      t = Time.now
      nom_fichier = "liste_des_horizons_#{t.strftime("%Y-%m-%d_%HH%M-%Ssec")}-#{t.usec}.xlsx"
      RapportMailer.rapport_listes_horizons(current_admin_utilisateur, @hash_pm, @tableau_annees, nom_fichier).deliver
    end
  end
end

I also have a view to display when report is sent with success : app/views/projects/reports/horizon_lists.html.haml

= content_for :titre do
  = render :partial => 'shared/main_title', :locals => { :titre => t('.title') }

.groupe-champs
  %p
    Le rapport a été envoyé sur votre adresse e-mail
    = current_admin_utilisateur.email
    \.

.separator
.bordure-inferieure

= content_for :sidebar do
  = render :partial => 'shared/sidebar_title', :locals => { :titre => nil }

I'd be gratefull if you could give me some advice on this.
Thanks

ActionController::UnknownFormat if no explicit action is specified in the controller

Whilte http://localhost:3005/de/projects/1/boilerplate_copies.xlsx results in Rails sending me some attachment, http://localhost:3005/de/projects/1/findings.xlsx results in ActionController::UnknownFormat.

I have the following two files, which both are empty:

  • app/views/findings/index.xlsx.axlsx
  • app/views/boilerplate_copies/index.xlsx.axlsx

Then I found out that the BoilerplateCopiesController has an explicit #index action, while FindingsController doesn't.

According to my knowledge, it's not Rails-style to require the controller to have an action explicitly defined - it's enough to have a view for it. So I guess this is a bug - or at least an annoyance that should be improved.

How to setup output excel file with group-by columns

Hi, after using this gem to generate excel file, I found columns in generated worksheet cannot execute operations of 'group-by' (group columns into a group so that I can expand/shrink group of columns). Is there any way to avoid this situation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.