Bill,
Sorry for the delay, it's been a busy day today. Currently there isn't a function specific to draw borders, but one of the overloads of SetCellFormat takes as last parameter a "ExteriorBorders" boolean. When true, this setcellformat will draw a box over the cells.
Here is a simple application showing how it would work:
program Project58;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils, VCL.FlexCel.Core, FlexCel.XlsAdapter;
procedure DrawBorders(const Xls: TExcelFile; const a1, a2: TCellAddress;
const BorderStyle: TFlxBorderStyle; const BorderColor: TExcelColor);
var
Fmt: TFlxFormat;
ApplyFmt: TFlxApplyFormat;
begin
Fmt := Xls.GetDefaultFormat;
Fmt.Borders.Left := TFlxOneBorder.Create(BorderStyle, BorderColor);
Fmt.Borders.Right := Fmt.Borders.Left;
Fmt.Borders.Top := Fmt.Borders.Left;
Fmt.Borders.Bottom := Fmt.Borders.Left;
ApplyFmt.SetAllMembers(false);
ApplyFmt.Borders.SetAllMembers(true);
Xls.SetCellFormat(a1.Row, a1.Col, a2.Row, a2.Col, Fmt, ApplyFmt, true);
end;
var
Xls: TXlsFile;
begin
Xls := TXlsFile.Create(1, TExcelFileFormat.v2013, true);
try
DrawBorders(Xls, TCellAddress.Create('B2'), TCellAddress.Create('D5'), TFlxBorderStyle.Thin, Colors.Black);
Xls.Save('r:\test.xlsx');
finally
Xls.Free;
end;
end.
It isn't really complex, but this post got me thinking that we could add a "SetBorders" method to TXlsFile which would basically do the same as the "DrawBorders" method above. It will probably be much easier to find than the SetCellFormat with ExteriorBorders = true. On the other side, one nice thing of SetCellFormat over a "DrawBorders" is that SetCellFormat can do the borders and other stuff at the same time. For example, you could set the borders and the fill color in the same call by changing the ApplyFmt variable above.