Definition- DrillDownGroupLevel is a system defined function in Crystal Reports ,that returns the current drill down level in the report that one is working upon. DrllDownGroupLevel can be used efficeintly and dynamically to achieve more interactivity and dynamism in a report.
Returns-Number (drill down group number).
Can be Used with:Formula Fields,Database fields,Text Fields.
Not compatible with:Custom report functions.
Drill path:Text Path showing the drill down in the running report.
I wanted to display the Drill Path in different colors i.e
1. Blue-Currently active Drill down Group(s).
2.Gray-Curently not active drill down group(s).
3.The whole report should yield a proper alignment when exported to Excel (xls).
Crystal report xi doesn’t support formatting a specific part of a string with a color of a specific choice based on a specific condition or not based on any condition. Crystal reports xi aligns the objects according to the x,y coordinate values.When the whole thing gets exported to formats like PDF it appears as it is because viewing applications like these follow a WYSIWYG (What You See Is What You Get)format.But with excel the things are different as it aligns the whole thing using indents,so things at the end of the day can be a mess.
Create a new formula –> Name it as per ur choice –> Enter the following code:
SWITCH( DrillDownGroupLevel=0,"Drill Path : <font color=#2149B4>DrillDownGroupLevel 0</font> <font color=#A2A2A2>> DrillDownGroupLevel 1 > DrillDOwnGroupLevel 2</font>",
DrillDownGroupLevel=1,"Drill Path : <font color=#A2A2A2>DrillDownGroupLevel 0</font><font color=#2149B4>> DrillDownGroupLevel 1</font> > <fontcolor=#A2A2A2>DrillDOwnGroupLevel 2</font>",
DrillDownGroupLevel=2,"Drill Path : <font color=#A2A2A2>DrillDownGroupLevel 0 > DrillDownGroupLevel 1</font> <font color=#2149B4>> DrillDownGroupLevel 2</font>",
After you are done writing the code –> Check for errors –>Click ‘Save and Close’ –>Design View –>Drag it and place it the Page header(or anywhere as per requirement (but not in the details section)–> Right Click on the formula field u just created –>Select Format Field from context menu–>Goto to Paragraph Tab–>On the ‘Text Interpretation’ drop down list select ‘Html Text’ –> Click ok and exit.
Explanation: Instead of using system defined or customization, this can be achieved by using <hmtl> tag formatting with <font color=#2149B4>> DrillDownGroupLevel 1</font> to the resultant string.I formatted the whole returning string in the html format so the text was formatted with a color as per the html color formatting.