ruby-on-railsaxlsx

Rails Gem "Axlsx" / "Rails-Axlsx" - Paper size to A4


I want to pass with the template test.xlsx.axlsx the paper_format. This should be A4, also

:paper_size => 9

I try this code :

wb.add_worksheet(:name => "Basic Worksheet") do |sheet|  

    .
    .
    .

    sheet.column_widths 2 , 11, 11, 11, 11, 23, 3

    #page_setup
    sheet.page_setup.fit_to :paper_size => 9 

end

But this doesnt work. How can i fix this ?


Solution

  • There is no page size in Axlsx for an entire workbook from what I can tell. Spreadsheets don't consider this until they print.

    But you can do it on a sheet by sheet basis:

    https://github.com/randym/axlsx/blob/master/examples/example.rb#L601-L612