2009-03-18 17 views
3

Ich fragte mich, ob es möglich ist, Formeln eines Kristallberichts programmatisch zu ändern. Ich möchte alle Formeln eines Berichts in meiner Web-App auflisten und dem Benutzer die Möglichkeit geben, sie zu ändern.Programmatically ändern Kristallreportformeln

Ist das möglich?

Antwort

4
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); 
      } 
     } 
    } 
} 
2

Ja, zum Beispiel verwenden wir die follwoing Funktion Formeln zu ändern:

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 
+0

Ist es möglich, zu ändern, ob die Syntax der Formel Kristall oder Basic ist? Frage: http://stackoverflow.com/questions/2386710/how-to-programmatical-change-a-crystal-reports-formula-from-crystal-syntax-to-b – Rory

Verwandte Themen