Cross Tab Matrix Formatting
When adding rows to a TppCrossTab's Matrix I noticed that all the cells in
the added rows take on the cell formatting of the Top Dimension for a Cross
tab. Or at least in my cross tab it only has one dimension.
My quesiton is why does it do this?
And is there any way to controll how a cell is formatted when or after a new
row is added to the Matrix?
I tried using the OnFormat event for the Cross Tab and that didn't work.
I did the following to add additional rows to the Cross Tab matrix.
procedure TfmDR.CrossTabMatrix(var lCrosstab: TppCrosstab);
var
Mrow, Mcol: Integer;
liColCount, liRowCount: Integer;
lsText: String;
lValue: Double;
lMatrix: TppMatrix;
begin
lMatrix := lCrossTab.Matrix;
liColCount := lMatrix.ColumnCount;
liRowCount := lMatrix.RowCount;
for Mrow := 2 to liRowCount - 1 do
begin
lMatrix.AppendRows(1, dtString);
for Mcol := 2 to liColCount - 2 do
begin
lValue := (lMatrix.Value[Mcol, Mrow] / lMatrix.Value[liColCount - 1,
Mrow]) * 100.0;
lsText := FloatToStrF(lValue, ffFixed, 15, 2) + '%';
lValue := lMatrix.Value[Mcol, Mrow];
lsText := FloatToStrF(lValue, ffNumber, 15, 0) + ' ' + lsText;
lMatrix.Value[Mcol, lMatrix.RowCount - 1] := VarAsType(lsText, $0100);
end;
lMatrix.Value[lMatrix.ColumnCount - 1, lMatrix.RowCount - 1] :=
FloatToStrF(lMatrix.Value[lMatrix.ColumnCount - 1, Mrow], ffNumber, 15, 0);
lMatrix.Value[0, lMatrix.RowCount - 1] := lMatrix.Value[0, Mrow] ;
lMatrix.Value[1, lMatrix.RowCount - 1] := lMatrix.Value[1, Mrow] ;
end;
lMatrix.DeleteRows(2, liRowCount - 1);
end;
the added rows take on the cell formatting of the Top Dimension for a Cross
tab. Or at least in my cross tab it only has one dimension.
My quesiton is why does it do this?
And is there any way to controll how a cell is formatted when or after a new
row is added to the Matrix?
I tried using the OnFormat event for the Cross Tab and that didn't work.
I did the following to add additional rows to the Cross Tab matrix.
procedure TfmDR.CrossTabMatrix(var lCrosstab: TppCrosstab);
var
Mrow, Mcol: Integer;
liColCount, liRowCount: Integer;
lsText: String;
lValue: Double;
lMatrix: TppMatrix;
begin
lMatrix := lCrossTab.Matrix;
liColCount := lMatrix.ColumnCount;
liRowCount := lMatrix.RowCount;
for Mrow := 2 to liRowCount - 1 do
begin
lMatrix.AppendRows(1, dtString);
for Mcol := 2 to liColCount - 2 do
begin
lValue := (lMatrix.Value[Mcol, Mrow] / lMatrix.Value[liColCount - 1,
Mrow]) * 100.0;
lsText := FloatToStrF(lValue, ffFixed, 15, 2) + '%';
lValue := lMatrix.Value[Mcol, Mrow];
lsText := FloatToStrF(lValue, ffNumber, 15, 0) + ' ' + lsText;
lMatrix.Value[Mcol, lMatrix.RowCount - 1] := VarAsType(lsText, $0100);
end;
lMatrix.Value[lMatrix.ColumnCount - 1, lMatrix.RowCount - 1] :=
FloatToStrF(lMatrix.Value[lMatrix.ColumnCount - 1, Mrow], ffNumber, 15, 0);
lMatrix.Value[0, lMatrix.RowCount - 1] := lMatrix.Value[0, Mrow] ;
lMatrix.Value[1, lMatrix.RowCount - 1] := lMatrix.Value[1, Mrow] ;
end;
lMatrix.DeleteRows(2, liRowCount - 1);
end;
This discussion has been closed.
Comments
of how to accomplish this. In the demo new rows are added to the crosstab in
the AfterCalc event and then certain cells are individially formatted in the
OnFormat event.
http://www.digital-metaphors.com/tips/CrossTabPercentages.zip
--
Cheers,
Alexander Kramnik
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
However the formatting falls over onto all of the added rows of the matrix.
Even when I do this
if aColumn = 3 then
aElement.Font.Color := clBlue;
It formats all of the first Dimension font blue.
I don't know if this is related, but I am trying to do the formatting in
RAP.
Bill
"Alexander Kramnik (Digital Metaphors)" wrote
if aColumn = 3 then
aElement.Font.Color := clBlue
else
aElement.Font.Color := clSomeColor.
This is because the element is used to format multiple cells and does not
reset itself after you set formatting options on it.
--
Cheers,
Alexander Kramnik
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
passthrough function.
"Alexander Kramnik (Digital Metaphors)" wrote
element of that set is available as a boolean property:
aElement.Font.Bold := True;
aElement.Font.Italic := True;
aElement.Font.Underline := True;
Cheers,
Tom Ollar
Digital Metaphors Corporation
http://www.digital-metaphors.com
info@digital-metaphors.com