Merging cells with a Ruby Gem table

How to merge cells using Ruby Spreadsheet gem. I would like to combine the first 6 cells in the first row of the sheet. When I try the following, it will not work:

merge_format = Spreadsheet::Format.new :align => :merge 6.times do |j| sheet.row(0).set_format(j,merge_format) end 

What am I doing wrong?

+6
source share
1 answer

You can just do

 sheet.merge_cells(start_row, start_col, end_row, end_col) 

If you want to go with set_format , I would advise you to try :vertical_align => :merge , although I did not use it, since merge_cells always worked for me.

+20
source

Source: https://habr.com/ru/post/921085/


All Articles