Merged Cell Borders

Just wondering if there is an easy way to put a border round a set of merged cells?

Say I have a 3x3 merged cell, ie xls.MergeCells(1,1,3,3), and I want to put a border around the outside.

APIMate shows putting a Top/Left border on Cell(1,1), Top border on Cell(1,2), Top/Right border on Cell(1,3), etc, etc, a finally Bottom/Right border on Cell(3,3) 

Just wondering if there is a helper method already written to enable me to do this in a single call. If not, I'll just write my own ;)


Yes, there is a method for this, just APIMate isn't smart enough to suggest it :)

The main issue though is that you need to use a "Apply" pattern since you want only to modify the borders and not the full format of all the cells. The last parameter "exteriorBorders" is what you set to draw only the outside borders of the range.

The code would be like this:
  fmt := xls.GetCellVisibleFormatDef(1, 1);
  fmt.Borders.SetAllBorders(TFlxBorderStyle.Thin, Colors.Black);
  applyFormat := TFlxApplyFormat.Create; applyFormat.SetAllMembers(false);

  xls.SetCellFormat(1, 1, 3, 3, fmt, applyFormat, true);


But I think we could also add a "DrawBorders" method that does all of the above in a single call.
I'll see to add it for the next version, but in the meantime the code above should do it.

Works perfectly. Thank you.