Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1168
  • Last Modified:

How do I set conditional formatting in Excel from a Delphi program using OLE

I've used
oWB := oXL.Workbooks.add;
oSheet := oWB.activesheet;

This bit works and I can produce an excel sheet but can't get the conditional formatting to work

oSheet.Range['C7:C7'].FormatConditions.add(    ,      ,    ,    )

is the part where I am having trouble.  What do I enter to get a condition of greater than 1
0
s_w_e2
Asked:
s_w_e2
1 Solution
 
aflarinCommented:
procedure TForm1.Button2Click(Sender: TObject);
const
  xlCellValue = $00000001;
const
  xlGreater = $00000005;
begin
  WorkSheet.Cells[1,1].FormatConditions.Add(xlCellValue,xlGreater,1);
  WorkSheet.Cells[1,1].FormatConditions[1].Interior.ColorIndex := 3;
end;
0
 
s_w_e2Author Commented:
Thanks for the solution.  It was great.
Is there a place I can get the format for this - my original try had 4 parameters - yours had only 3  (I've figured that you need 4 if you use xlBetween  (I've got a list of numbers for these).

Can you also give me the format for validation of a cell?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now