cancel
Showing results for 
Search instead for 
Did you mean: 

Extraction of Crosstab and Chart Metadata ( like Columns and Rows used in those particular objects) using Crystal Report SDK.

Former Member
0 Kudos

Hi,

I am new to Crystal Report SDKs and right now i am trying to extract

1) Crosstab and Chart Metadata (Columns and Rows) i.e fact and measure information in 3.1

2) Sectionwise object details(For eg, In page header a what are the objects used likewise)

But i am not sure which object method and which version of SDK to use to get those information.

Is that possible to get those metadata informations using latest SDK?

Kindly help me with this.

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello,

You need to use CR for VS, you can get the installer for VS from the Overview tab link.

There are no API's for Crosstabs, just basic location properties is all. If you need to create a manual Crosstab, then you can adjust it's properties.

To get most of the object info here something to get you going...

Requires RAS to get the info and the ReportClientDocument. Samples are also on the Overview tab of this forum.

btnReportObjects is a text box to dump the info into.

case "Object Name -> Field Name":

    #region OBJtoFName

    btnReportObjects.Text = "";

    textBox1 = "";

    flcnt = 0;

    CrystalDecisions.ReportAppServer.ReportDefModel.ReportObjects rptObjs;

    //rptObjs = rptClientDoc.ReportDefController.ReportObjectController.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindField);

    rptObjs = rptClientDoc.ReportDefController.ReportObjectController.GetAllReportObjects();

    foreach (CrystalDecisions.ReportAppServer.ReportDefModel.ReportObject rptObj1 in rptObjs)

    {

        switch (rptObj1.Kind)

        {

            case CrReportObjectKindEnum.crReportObjectKindField:

                CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject fldObj1;

                fldObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject)rptObj1;

                               

                textBox1 = fldObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += fldObj1.DataSourceName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                //// This works do not change

                //if (fldObj1.Name == "LINETOTALTAXAMOUNT1")

                //{

                //    CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject OldfieldObject = (CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject)rptObj1;

                //    CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject NewfieldObject = new CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject();

                //    //OldfieldObject.CopyTo(NewfieldObject, true);

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

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

                //    //CrystalDecisions.ReportAppServer.ReportDefModel.CrCurrencySymbolTypeEnum = CrCurrencySymbolTypeEnum.crCurrencySymbolTypeFixedSymbol;

                //    numericFieldFormat.NDecimalPlaces = 8;

                //    numericFieldFormat.EnableUseLeadZero = false;

                //    //numericFieldFormat.ThousandSymbol = "&";

                //    //numericFieldFormat.ThousandsSeparator = true;

                //    numericFieldFormat.NegativeFormat = CrystalDecisions.ReportAppServer.ReportDefModel.CrNegativeTypeEnum.crNegativeTypeLeadingMinus;

                //    numericFieldFormat.RoundingFormat = CrystalDecisions.ReportAppServer.ReportDefModel.CrRoundingTypeEnum.crRoundingTypeRoundToTenBillionth;

                //    rptClientDoc.ReportDefController.ReportObjectController.Modify(OldfieldObject, NewfieldObject);

                //    // Another bug in the controller need to call this 2 times to take the Rounding property - same as ADAPT01727457

                //    rptClientDoc.ReportDefController.ReportObjectController.Modify(OldfieldObject, NewfieldObject);

                //    IsRpt = false;

                //}

                //// This works do not change

                break;

            case CrReportObjectKindEnum.crReportObjectKindText:

                CrystalDecisions.ReportAppServer.ReportDefModel.TextObject txtObj;

                txtObj = (CrystalDecisions.ReportAppServer.ReportDefModel.TextObject)rptObj1;

                textBox1 = txtObj.Name.ToString();

                textBox1 += " -> " + txtObj.Text.ToString();

                textBox1 += "\nEnableSuppressEmbedBlankLines: " + ((dynamic) rptObj1).TextObjectFormat.EnableSuppressEmbedBlankLines + "\n";

                textBox1 += "SectionCode: " + ((dynamic) rptObj1).SectionCode;

                btnReportObjects.Text += textBox1 + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                //// This works do not change

                //if (txtObj.Name == "Text1")

                //{

                //    CrystalDecisions.ReportAppServer.ReportDefModel.TextObject OldTextObject = (CrystalDecisions.ReportAppServer.ReportDefModel.TextObject)rptObj1;

                //    CrystalDecisions.ReportAppServer.ReportDefModel.TextObject NewTextObject = new CrystalDecisions.ReportAppServer.ReportDefModel.TextObject();

                //    //OldfieldObject.CopyTo(NewfieldObject, true);

                //    NewTextObject = (CrystalDecisions.ReportAppServer.ReportDefModel.TextObject)OldTextObject.Clone(true);

                //    NewTextObject.Border.BackgroundColor = 255;

                //    rptClientDoc.ReportDefController.ReportObjectController.Modify(OldTextObject, NewTextObject);

                //    //rptClientDoc.ReportDefController.ReportObjectController.Modify(OldTextObject, NewTextObject);

                //    IsRpt = false;

                //}

                //// This works do not change

                break;

            case CrReportObjectKindEnum.crReportObjectKindBox:

                CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject boxObj1;

                CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject boxObj2 = new CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject();

                boxObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject)rptObj1;

                boxObj2 = boxObj1;

                //// modify the box size

                //boxObj.Bottom = 360;

                //boxObj1.Height = 2385;

                //boxObj1.Format.EnableCanGrow = true;

                //boxObj1.EndSectionName = "ReportFooterSection1";

                //boxObj1.EnableExtendToBottomOfSection = true;

                //rptClientDoc.ReportDefController.ReportObjectController.Modify(boxObj, boxObj1);

                textBox1 = boxObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += boxObj1.Name.ToString();

                textBox1 += " : X - ";

                textBox1 += (boxObj1.Left / 1440.00).ToString();

                textBox1 += " : Y - ";

                textBox1 += ((boxObj1.Right - boxObj1.Left) / 1440.00).ToString();

                textBox1 += " : Width - ";

                textBox1 += (boxObj1.Width / 1440.00).ToString();

                textBox1 += " : Height - ";

                textBox1 += (boxObj1.Height / 1440.00).ToString();

                btnReportObjects.Text += textBox1 + "\n";

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                IsRpt = false;

                break;

            case CrReportObjectKindEnum.crReportObjectKindPicture:

                textBox1 = rptObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += rptObj1.Name.ToString();

                btnReportObjects.Text += textBox1;

                btnReportObjects.AppendText("\n");

                btnReportObjects.Text += "Height: " + rptObj1.Height.ToString();

                btnReportObjects.AppendText(" Twips\n");

                btnReportObjects.Text += "Width: " + rptObj1.Width.ToString();

                btnReportObjects.AppendText(" Twips\n");

                btnReportObjects.Text += "Top: " + rptObj1.Top.ToString();

                btnReportObjects.AppendText(" Twips\n");

                btnReportObjects.Text += "Left: " + rptObj1.Left.ToString();

                btnReportObjects.AppendText(" Twips\n");

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                break;

            case CrReportObjectKindEnum.crReportObjectKindChart:

                textBox1 = rptObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += rptObj1.Name.ToString();

                btnReportObjects.Text += textBox1;

                btnReportObjects.AppendText("\n");

                btnReportObjects.Text += "Height: " + rptObj1.Height.ToString();

                btnReportObjects.AppendText(" Twips\n");

                btnReportObjects.Text += "Width: " + rptObj1.Width.ToString();

                btnReportObjects.AppendText(" Twips\n");

                btnReportObjects.Text += "Top: " + rptObj1.Top.ToString();

                btnReportObjects.AppendText(" Twips\n");

                btnReportObjects.Text += "Left: " + rptObj1.Left.ToString();

                btnReportObjects.AppendText(" Twips\n");

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                break;

            case CrReportObjectKindEnum.crReportObjectKindSubreport:

                CrystalDecisions.ReportAppServer.ReportDefModel.SubreportObject subObj1;

                subObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.SubreportObject)rptObj1;

                textBox1 = subObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += subObj1.SubreportName.ToString() + " - ";

                btnReportObjects.Text += textBox1;

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionCode.ToString() + " " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                break;

            case CrReportObjectKindEnum.crReportObjectKindOlapGrid:

                CrystalDecisions.ReportAppServer.ReportDefModel.OlapGridObject OLAPObj1;

                OLAPObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.OlapGridObject)rptObj1;

                textBox1 = OLAPObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += OLAPObj1.Name.ToString() + " - ";

                btnReportObjects.Text += textBox1;

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionCode.ToString() + " " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                break;

            case CrReportObjectKindEnum.crReportObjectKindMap:

                CrystalDecisions.ReportAppServer.ReportDefModel.MapObject MapObj1;

                MapObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.MapObject)rptObj1;

                textBox1 = MapObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += MapObj1.Name.ToString() + " - ";

                btnReportObjects.Text += textBox1;

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionCode.ToString() + " " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                break;

            case CrReportObjectKindEnum.crReportObjectKindLine:

                CrystalDecisions.ReportAppServer.ReportDefModel.LineObject LineObj1;

                LineObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.LineObject)rptObj1;

                textBox1 = LineObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += LineObj1.Name.ToString() + " - ";

                btnReportObjects.Text += textBox1;

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionCode.ToString() + " " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                break;

            case CrReportObjectKindEnum.crReportObjectKindFlash:

                CrystalDecisions.ReportAppServer.ReportDefModel.FlashObject FlashObj1;

                FlashObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.FlashObject)rptObj1;

                textBox1 = FlashObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += FlashObj1.Name.ToString() + " - ";

                btnReportObjects.Text += textBox1;

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionCode.ToString() + " " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                break;

            case CrReportObjectKindEnum.crReportObjectKindFieldHeading:

                CrystalDecisions.ReportAppServer.ReportDefModel.FieldHeadingObject FieldHeadingObj1;

                FieldHeadingObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.FieldHeadingObject)rptObj1;

                textBox1 = FieldHeadingObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += FieldHeadingObj1.Name.ToString() + " - ";

                btnReportObjects.Text += textBox1;

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionCode.ToString() + " " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                break;

            case CrReportObjectKindEnum.crReportObjectKindCrosstab:

                CrystalDecisions.ReportAppServer.ReportDefModel.CrossTabObject CrossObj1;

                CrossObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.CrossTabObject)rptObj1;

                textBox1 = CrossObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += CrossObj1.Name.ToString() + " - ";

                btnReportObjects.Text += textBox1;

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionCode.ToString() + " " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                break;

            case CrReportObjectKindEnum.crReportObjectKindBlobField:

                CrystalDecisions.ReportAppServer.ReportDefModel.BlobFieldObject BlobObj1;

                BlobObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.BlobFieldObject)rptObj1;

                textBox1 = BlobObj1.Name.ToString();

                textBox1 += " -> ";

                textBox1 += BlobObj1.Name.ToString() + " - ";

                btnReportObjects.Text += textBox1;

                btnReportObjects.Text += "Section Name: " + rptObj1.SectionCode.ToString() + " " + rptObj1.SectionName.ToString() + "\n";

                btnReportObjects.AppendText("ToolTip: " + rptObj1.Format.ToolTipText.ToString() + "\n\n");

                ++flcnt;

                btnCount.Text = flcnt.ToString();

                break;

            //case CrReportObjectKindEnum.crReportObjectKindInvalid:

            //    CrystalDecisions.ReportAppServer.ReportDefModel. InvalidObj1;

            //    BlobObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.BlobFieldObject)rptObj1;

            //    textBox1 = BlobObj1.Name.ToString();

            //    textBox1 += " -> ";

            //    textBox1 += BlobObj1.Name.ToString() + " - ";

            //    btnReportObjects.Text += textBox1;

            //    btnReportObjects.Text += "Section Name: " + rptObj1.SectionCode.ToString() + " " + rptObj1.SectionName.ToString() + "\n";

            //    btnReportObjects.AppendText("\n");

            //    ++flcnt;

            //    btnCount.Text = flcnt.ToString();

            //    break;

            //    //CrystalDecisions.ReportAppServer.ReportDefModel.CrReportObjectKindEnum.crReportObjectKindInvalid;

        }

    }

    #endregion OBJtoFName

    break;

And a few bonus commented routines to alter the info.

Don

Answers (0)