Conditional formatting

Use this code to create cells with conditional formatting:
uses
  {...}, OExport, OExport_Vcl, OExport_VclForms;

procedure TForm1.BtnTestClick(Sender: TObject);
var
  xExport: TOExport;
  I, L: Integer;
begin
  xExport := TOExport.Create;
  try
    with xExport.AddWorkSheet('Conditional formatting') do begin
      AddRow.AddCellString(Title).SetFontSize(20);
      Cols[0].Width := 200;
      Cols[1].Width := 150;

      AddRow;
      AddRow.AddCellString('Constant numbers as limits').SetFontStyle([fsBold]);
      for I := 0 to 9 do begin
        with AddRow.AddCellNumber(I).ConditionalFormatting do begin
          AddRule(ecEqual, 0).SetFontColor(clWhite).SetBGColor(clRed);
          AddRule(ecGreaterEqual, 2).SetFontColor(clYellow).SetBGColor(clBlue);
          AddRule(ecBetween, 6, 8).SetFontColor(clWhite).SetBGColor(clGreen).
            SetFontStyle([fsBold]);
        end;
      end;

      AddRow;
      AddRow;
      AddRow.AddCellString('Formulas as limits').SetFontStyle([fsBold]);
      with AddRow.AddCellNumber(7).ConditionalFormatting do begin
        AddRule(ecBetween, 'A6', 'A13').SetFontColor(clRed).SetBGColor(clYellow);
      end;
    end;

    xExport.SaveToFileWithDialog;
  finally
    xExport.Free;
  end;
end;
Categories