[英]Rails Gem "Axlsx" / "Rails-Axlsx" - Paper size to A4
I want to pass with the template test.xlsx.axlsx the paper_format.我想通过模板 test.xlsx.axlsx paper_format。 This should be A4, also
这应该是A4,也
: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 ?
我怎样才能解决这个问题 ?
There is no page size in Axlsx for an entire workbook from what I can tell. 据我所知,Axlsx中没有整个工作簿的页面大小。 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 https://github.com/randym/axlsx/blob/master/examples/example.rb#L601-L612
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
我从这里找到的设置选项: 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.他说,A4 纸(210 毫米 x 297 毫米)的默认参数是 9。
Sometime when you are printing it will show the custom ,but it's actually A4.有时在打印时会显示自定义,但实际上是 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.