Hi,
Please tell me the code draw a border around the cell.
Maybe it is that simple.But I can not find it .
Incidentally, Im using the TMS FlexCel for VCL.
Thanks and best regards,
TARO
Hi,
//Set the cell values
fmt := xls.GetCellVisibleFormatDef(2, 2);
fmt.Borders.Left.Style := TFlxBorderStyle.Thin;
fmt.Borders.Left.Color := TExcelColor.Automatic;
fmt.Borders.Right.Style := TFlxBorderStyle.Thin;
fmt.Borders.Right.Color := TExcelColor.Automatic;
fmt.Borders.Top.Style := TFlxBorderStyle.Thin;
fmt.Borders.Top.Color := TExcelColor.Automatic;
fmt.Borders.Bottom.Style := TFlxBorderStyle.Thin;
fmt.Borders.Bottom.Color := TExcelColor.Automatic;
xls.SetCellFormat(2, 2, xls.AddFormat(fmt));
/// <summary>
/// Changes part of the Cell format on a range of cells. WARNING! This method is slower than the other SetCellFormat versions, use it only
/// if you do not care about maximum performance or if you just can't use the other SetCellFormat versions.
/// This particular version of SetCellFormat has to read the format on each cell, modify it and write it back.
/// While still very fast, it is not as fast as just setting the format on a cell.
/// </summary>
/// <remarks>
/// You can use this method for example to add a border on the top of a row of cells, keeping the existing font and pattern styles on the range.
/// </remarks>
/// <param name="row1">Row index of the top cell on the range (1 based)</param>
/// <param name="col1">Column index of the left cell on the range (1 based)</param>
/// <param name="row2">Row index of the bottom cell on the range (1 based)</param>
/// <param name="col2">Column index of the right cell on the range (1 based)</param>
/// <param name="newFormat">Format to apply to the cells.</param>
/// <param name="applyNewFormat">Indicates which properties of newFormat will be applied to the cells.</param>
/// <param name="exteriorBorders">When true, the format for the border will be applied only to the outer cells in the range. This can
/// be useful for example to draw a box around a range of cells, but not drawing borders inside the range.
/// Other parameters, like the cell background, will still be applied to the full range.</param>
procedure SetCellFormat(const row1: Int32; const col1: Int32; const row2: Int32; const col2: Int32; const newFormat: TFlxFormat; const applyNewFormat: TFlxApplyFormat; const exteriorBorders: Boolean); overload; virtual; abstract;
//Add a rectangle around the cells
ApplyFormat := TFlxApplyFormat.Create;
ApplyFormat.SetAllMembers(false);
ApplyFormat.Borders.SetAllMembers(true); //We will only apply the borders to the existing cell formats
fmt := Xls.GetDefaultFormat;
fmt.Borders.Left.Style := TFlxBorderStyle.Double;
fmt.Borders.Right.Style := TFlxBorderStyle.Double;
fmt.Borders.Top.Style := TFlxBorderStyle.Double;
fmt.Borders.Bottom.Style := TFlxBorderStyle.Double;
Xls.SetCellFormat(DataCell.Top - 1, DataCell.Left, DataCell.Top, DataCell.Left + 1, fmt, ApplyFormat, true); //Set last parameter to true so it draws a box.