0

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 ?

Drextor
  • 433
  • 1
  • 6
  • 24

2 Answers2

1

Here you are. The setting option I found from here : https://www.rubydoc.info/github/randym/axlsx/Axlsx%2FPageSetup:paper_size https://github.com/randym/axlsx/blob/master/lib/axlsx/workbook/worksheet/page_setup.rb#L49

A4 paper (210 mm by 297 mm)'s default parameter is 9 ,he said.

Sometime when you are printing it will show the custom ,but it's actually A4.

wb.add_worksheet(:name => "Basic Worksheet", :page_setup => {:paper_size  => 9}) do |sheet|  

    .
    .
    .

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

end
Zan Zas
  • 501
  • 5
  • 6
0

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

noel
  • 2,095
  • 14
  • 14