randym/axlsx — Issue #18: Merging/formatting cells past end of row
Author: dkmdnielsen
Created: 2012-01-13 21:48:53+00:00
State: open

Given the following:

```ruby
ws.add_row [nil,nil,nil,nil,nil,nil,nil,'Carrier Route Discount',nil]
ws.add_row [nil,nil,nil,nil,nil,nil,nil,'Additional Book Cost',nil]
ws.add_row [[@prj.client,'#'+@prj.proj,@prj.deptrun].join('.') + Time.now.strftime(" %Y/%m/%d %H:%M")]
...
(0..2).each {|i| ws.merge_cells ws.rows[i].cells[0..4] }

```

When the merge_cells executes, it merges columns A..E just fine for the first two rows. However, it fails to do so for the final row. Columns B..E do not merge because those rows do not contain populated cell instances for those columns. This affects styles, as well.

Something needs to be documented about this. It took a while to figure out.

The only solution to this, which I dread even saying, is that the system would need to keep a perfect square of columns populated. If a row is created that has more cells than previous, then the previous ones would need to be filled.

Another possible solution would be to have functions that are sensitive to columns to fill them in. If the function says columns 3..7 when only five cells exist in the row, then the remaining two fields would be created by the function, filling in the need.

While I don't admire either approach, I think the system needs to intelligently respond to the missing cells. Systems are going to use this product to generated stuff on the fly. Reports and stuff will come out looking funny.