Programmatically change crystal report formulas

2019-02-24 09:53发布

I was wondering if it is possible to change formulas of a crystal report programmatically. I want to list all formulas of a report in my web app and give the user the possibility to modify them.

Is that possible?

2条回答
走好不送
2楼-- · 2019-02-24 10:10
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);
            }
        }
    }
}
查看更多
\"骚年 ilove
3楼-- · 2019-02-24 10:17

Yes, for example we use the follwoing 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
查看更多
登录 后发表回答