Skip to Content
avatar image
Former Member

For ... Loop

Hi experts,

I have hundreds of reports. It is the appearance of the decimal point and after it two zeros such as (.00). I tried to get rid of them by design in the C# framework that did not work. I want a code to be applied to all fields of decimal type to get rid of (.00).

greetings to you all

:)

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 11 at 04:24 PM

    Hi Mohamad,

    You need to use RAS and RCD Report Object and then clone the object, make the change and then preview:

    CrystalDecisions.ReportAppServer.ReportDefModel.ReportObjects rptObjs;
    rptObjs = rptClientDoc.ReportDefController.ReportObjectController.GetAllReportObjects();

    foreach (CrystalDecisions.ReportAppServer.ReportDefModel.ReportObject rptObj1 in rptObjs)
    {
    switch (rptObj1.Kind)
    {
    case CrReportObjectKindEnum.crReportObjectKindField:

    CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject OldfieldObject = (CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject)rptObj1;
    CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject NewfieldObject = new CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject();

    NewfieldObject = (CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject)OldfieldObject.Clone(true);

    CrystalDecisions.ReportAppServer.ReportDefModel.NumericFieldFormat numericFieldFormat = NewfieldObject.FieldFormat.NumericFormat;
    //CrystalDecisions.ReportAppServer.ReportDefModel.CrCurrencySymbolTypeEnum = CrCurrencySymbolTypeEnum.crCurrencySymbolTypeFixedSymbol;

    if (OldfieldObject.FieldFormat.NumericFormat.NDecimalPlaces != 0)
    {
    ((dynamic)NewfieldObject).FieldFormat.NumericFormat.NDecimalPlaces = 0;
    rptClientDoc.ReportDefController.ReportObjectController.Modify(OldfieldObject, NewfieldObject);
    rptClientDoc.ReportDefController.ReportObjectController.Modify(OldfieldObject, NewfieldObject);
    }

    }

    .....

    Don

    Add comment
    10|10000 characters needed characters exceeded