Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Axlsx_rails. Set height of multiple rows at once

I'm generating *.xlsx files using axlsx_rails based on xlsx gem.

I'm setting height for single row like this:

sheet.add_row [1,2,3,4,5,6], :style => predefined_style, :height => 14.3

How could I set height for a batch of rows, and if it possible, which declaration has higher priority?

like image 247
vvahans Avatar asked Nov 21 '25 03:11

vvahans


1 Answers

The best I know of is to set the height on each row:

sheet.rows.values_at(1,2,5,6).each {|row| row.height = 40}

If necessary you can gain access to the sheets through the workbook:

sheet = workbook.worksheets.first
# or
sheet = workbook.sheet_by_name("Sheet Name")

Whichever statement comes later has priority (meaning it isn't like CSS where inline has higher priority.)

like image 191
noel Avatar answered Nov 22 '25 17:11

noel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!