Programmatically change crystal report formulas

I was wondering if it is possible to programmatically change the formulas of the crystalline report. I want to list all the report formulas in my web application and give the user the opportunity to modify them.

Is it possible?

+3
source share
2 answers
using CrystalDecisions.CrystalReports.Engine;

namespace Craft
{
    class Mate
    {
        Order_Print _r = new Order_Print();

        void Preview()
        {
            foreach (FormulaFieldDefinition f in _r.DataDefinition.FormulaFields)
            {
                MessageBox.Show(f.Name);

                f.Text = InputBox.Show("Input the formula for " + f.Name);
            }
        }
    }
}
+4
source

Yes, for example, we use the following function to change formulas:

 Public Sub SetReportFormulaContents(ByRef Report As ReportDocument, ByVal FormulaName As String, ByVal FormulaContents As String)
    Dim Formula As FormulaFieldDefinition = Nothing

    ' Get the ReportObject by name and cast it as a FieldObject
    If TypeOf (Report.DataDefinition.FormulaFields.Item(FormulaName)) Is CrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition Then
        Formula = Report.DataDefinition.FormulaFields.Item(FormulaName)
        Formula.Text = FormulaContents
    End If
End Sub
+2
source

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


All Articles