Page 1 of 1
Cross-tab - highligthing max value
Posted: Wed May 14, 2014 7:32 am
by Dmitry
Is it possible to highlight max value in each column of cross-tab report?
So, only cell with Max value must be highlight in whole column.
BTW, I do need to calc totals for cross-tab, but not as "Sum" of each value in a column, but as "Max" value.
Unfortunately, I don't see built-in functionality for such a requirement.
I coped with it by this link
http://support.stimulsoft.com/index.php ... -cross-tab
But it seems to me, it would be better, if this functionality is built-in
Re: Cross-tab - highligthing max value
Posted: Wed May 14, 2014 12:25 pm
by Alex K.
Hello,
Please checkthe sample report in teh attachment.
http://forumru.stimulsoft.com/viewtopic.php?f=8&t=3619
Thanky ou.
Re: Cross-tab - highligthing max value
Posted: Tue May 20, 2014 5:19 am
by Dmitry
Thank you for for suggestion, resulting code looks like:
Code: Select all
using System.Collections.Generic;
private Dictionary<int, decimal> _maximums = new Dictionary<int, decimal>();
private void AddValue(int row, decimal valueToAdd) {
if (_maximums.ContainsKey(row)) {
var existingValue = _maximums[row];
if (existingValue < valueToAdd) {
_maximums[row] = valueToAdd;
}
} else {
_maximums.Add(row, valueToAdd);
}
}
bool IsMaxValue(int colNum, decimal val)
{
if (_maximums.ContainsKey(colNum))
{
return val == _maximums[colNum];
}
return false;
}
public void CrossTab1_Sum1_ProcessCell(object sender, Stimulsoft.Report.CrossTab.StiProcessCellEventArgs e)
{
if (IsFirstPass)
{
AddValue(e.Column, e.Value);
}
else
{
if (IsMaxValue(e.Column, e.Value))
{
Stimulsoft.Report.Components.StiConditionHelper.ApplyFont(sender,
new System.Drawing.Font("Arial", 8.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 204),
Stimulsoft.Report.Components .StiConditionPermissions.All);
}
}
}
Also you have to change report processing to double pass.
I don't see the way to accomplish this in 1-pass
Re: Cross-tab - highligthing max value
Posted: Tue May 20, 2014 5:59 am
by Alex K.
Hello,
Thank you for the information.
Let us know if you need any additional help.
Thank you.