Solved

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

Posted on 2010-08-31
2
1,045 Views
Last Modified: 2012-05-10
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
Comment
Question by:s_w_e2
2 Comments
 
LVL 13

Accepted Solution

by:
aflarin earned 500 total points
Comment Utility
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
 

Author Closing Comment

by:s_w_e2
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now