Search code examples
c#crystal-reports

How to change the "Repeat Group Header On Each Page" option of the Crystal Report group via C# code?


I am making a report in which I used the group to repeat the header of my grid. I made a group by one unique field and checked the option "Repeat Group Header On Each Page" which is good when I generate PDF, but when I generate Excel doc, that repeated header shows up in the middle of the table, so I need to change that in case I want to make an excel file.

Since I know how to access some formula in the report, maybe that can help to.

So, does anyone know how to solve this?

Thank you.


Solution

  • There is a function called: InRepeatedGroupHeader. If I apply formula to the Suppress option of the group in which header is defined and then in the code change it, it works.

    var formulaField = mainSubreport.DataDefinition.FormulaFields["RepeatHeader"];
    formulaField.Text = "if inrepeatedgroupheader then TRUE ELSE FALSE";