Last post Jul 13, 2010 08:03 PM by sansan
Jul 13, 2010 12:54 PM|ahanaysheh|LINK
Jul 13, 2010 02:01 PM|sansan|LINK
Instead of updating the formula of crystal report from asp.net code, it is advisable to insert the formula in the crystal itself.
Jul 13, 2010 06:14 PM|ahanaysheh|LINK
Thanks for your fast response,
but in this way i you asked me to rewrite it inside each font formula for each field, but am trying to loop over all currancy fields inside the report document from asp.net code then and update the font formula.
in other word i want to replace the XXX in the code below with the formula path:
Sub FormatReportCurrencyFields(ByVal rep
Integer = 0
To rep.ReportDefinition.Sections.Count - 1
Integer = 0
To rep.ReportDefinition.Sections(index).ReportObjects.Count - 1
If .ReportObjects(i).Kind = ReportObjectKind.FieldObject
As FieldObject = .ReportObjects(i)
If fb.DataSource.ValueType = FieldValueType.CurrencyField
OrElse fb.DataSource.ValueType = FieldValueType.NumberField
String = DirectCast(DirectCast(fb.DataSource, FieldDefinition), FormulaFieldDefinition).Text
String = "if " & FieldName &
" < 0 then" _
" crRed" _" Else " _" crBlack" _
XXX.text = str
Jul 13, 2010 08:03 PM|sansan|LINK
I never tried it that Way.
because Formula fields are the part of the ReportDefinition, not the Report Section.
I have done this in c#:
CrystalReport1 rep = new CrystalReport1();
rep.DataDefinition.FormulaFields["TestFormula"].Text = "\"Test Formula\"";
This updated my formula value.
If you are trying to find the column, I think you can set formula name for object format or field format.
Instead of finding the formula and updating the value, I prefer just creating the formula in the crystal report for the fields
It will be easy to manage changes in the crystal reports, It will update the report class.
If you have some code to update the fields in crystal, you will have to re compile the project to get the new updated dll.
correct me if I am wrong.