Conditional Formating

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
cherniak
Posts: 4
Joined: Wed Oct 07, 2009 1:06 pm

Conditional Formating

Post by cherniak »

Hello I'm trying to use Conditional Formating
I'm using Borland C++ Builder and XLSReadWriteII 3.0

My sorse code is following:
//**********************************************************************************************************************************//
XLS->Sheet[0]->FillRandom("A1:I10",300); //Add somw random numbers

XLS->Sheet[0]->ConditionalFormats->Add();
XLS->Sheet[0]->ConditionalFormats->Add()->Areas->Add(0,0,9,9);
XLS->Sheet[0]->ConditionalFormats->Add()->Condition1->Formula1="100";
XLS->Sheet[0]->ConditionalFormats->Add()->Condition1->Formula2="200";
XLS->Sheet[0]->ConditionalFormats->Add()->Condition1->CompOperator=coBetween;
XLS->Sheet[0]->ConditionalFormats->Add()->Condition1->FmtPattern->ForeColor=xcRed;
//**********************************************************************************************************************************//

In output XLS sheet it fills A1:I10 with random values from 0 to 300, but it does not do any frmating (does not color in red cells with values between 100 and 200)
What i'm doing wrong ??
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Conditional Formating

Post by larsa »

Hello

For every call to Add(), you adds a new conditional format, so at the end you have added six.
Here is a working delphi sample:

var
CondFmt: TConditionalFormat;
begin
XLSBook.XLS.Sheet[0].FillRandom('A1:I10',300); //Add somw random numbers

CondFmt := XLSBook.XLS.Sheet[0].ConditionalFormats.Add();
CondFmt.Areas.Add(0,0,9,9);
CondFmt.Condition1.Formula1 := '100';
CondFmt.Condition1.Formula2 := '200';
CondFmt.Condition1.CompOperator := coBetween;
CondFmt.Condition1.FmtPattern.ForeColor := xcRed;
end;
Lars Arvidsson, Axolot Data
cherniak
Posts: 4
Joined: Wed Oct 07, 2009 1:06 pm

Re: Conditional Formating

Post by cherniak »

OK,
But how to apally it for C++?
Can you give me code example ?
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Conditional Formating

Post by larsa »

Hello

Sorry, I don't have C++ installed, but assigning a value to a variable, and then use the variable, is just basic C++ programming.
Lars Arvidsson, Axolot Data
cherniak
Posts: 4
Joined: Wed Oct 07, 2009 1:06 pm

Re: Conditional Formating

Post by cherniak »

sorry but it does not work.
If you find some kind of example in C++
it would be grate help

many thx .
cherniak
Posts: 4
Joined: Wed Oct 07, 2009 1:06 pm

Re: Conditional Formating

Post by cherniak »

!
Post Reply