How to programmatically change a Crystal Reports formula from Crystal Syntax to Basic Syntax - in Visual Studio 2005

I want to programmatically change formulas in a variety of reports, for example this question , but I also need to change the formula between Crystal syntax and basic syntax. I see no way to do this in the object model. Is it possible?

i.e. I have a formula called "Period" that already exists in many reports, and is currently defined in Crystal Syntax. I want to set the formula in the basic syntax and provide updated formula text. I do not need to automatically convert the current definition from the crystal to the main; I already have a new formula text.

If I just go through all the reports, open them and then set the TextFieldDefinition Text property, then the formulas are still set to โ€œCrystal Syntaxโ€ and will not be evaluated correctly. Currently, my only solution is to open each report manually, edit the formula, change the drop-down list from Crystal syntax to the basic syntax.

+1
source share
3 answers

I believe and @CodeByMoonlight confirms that this is not available. Therefore, for those in the same boat as I, with many update reports: enjoy this manual process and hope that you never have to come back!

0
source

You can go through an objectmodel like this. Just change the formula and the name of the formula.

public ReportDocument GetReport(DataSet ds)
    {
        const string formula = "WhileReadingRecords;" +
                               "<<your formula>>";


        ReportDocument report = new InvoiceReport();
        report.SetDataSource(ds);

        // iterate report objects
        foreach (ReportObject ro in report.ReportDefinition.ReportObjects)
        {

            if ((ro.Kind == ReportObjectKind.FieldObject && ro.Name == "<<FormuleName>>"))
            {
                ((FormulaFieldDefinition) ((FieldObject) o).DataSource).Text = formula;
            }
        }
        return report;
    }
0
source

Source: https://habr.com/ru/post/1704940/


All Articles