Page 1 of 1

Conditional Formating

Posted: Wed Oct 07, 2009 1:28 pm
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 ??

Re: Conditional Formating

Posted: Thu Oct 08, 2009 2:29 pm
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;

Re: Conditional Formating

Posted: Thu Oct 08, 2009 3:40 pm
by cherniak
OK,
But how to apally it for C++?
Can you give me code example ?

Re: Conditional Formating

Posted: Thu Oct 08, 2009 4:49 pm
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.

Re: Conditional Formating

Posted: Mon Oct 12, 2009 8:55 am
by cherniak
sorry but it does not work.
If you find some kind of example in C++
it would be grate help

many thx .

Re: Conditional Formating

Posted: Wed Oct 21, 2009 10:35 am
by cherniak
!