9 Replies Latest reply: Jan 29, 2015 5:11 AM by corrado Chinotto RSS

    Is there any example that works for SDK.NET

    corrado Chinotto

      Sorry for the post but I continue to try and try again what you wrote in 'or' Help Qlik Sense for Developers Version: 1.0.2 "but no nothing works without having to make changes !!!

       

      You can post as a trivial application  that working!.

       

      In this case, I added the following code and does not enter into the foreach loop (Test(2) and Test(3))

       

      http://help.qlik.com/sense/en-us/developer/#../Subsystems/NetSdk/Content/HowTos/NetSdk_HowTo_ListObjects.htm%3FTocPath%3…

       

      My app contains 2 sheets with the following sheetobject

      Sheet (1) "Il mio nuovo foglio"

           SheetObject (1) :  Type:table ID:sFq

           SheetObject (2): Type:piechart ID:FUyeBYF

       

      Sheet (2) "Sheet2"

           SheetObject (1) :  Type:linechart ID:LJHaM

       

       

      //1) Test -

                  foreach (IGenericObject child in ASheet.Children  )

                  {

                      Console.WriteLine("1) Test -  Type:{0} ID:{1}", child.Info.Type, child.Info.Id);

                   }

      //2) Test - this code does not enter

                  foreach (IPiechart child in ASheet.Children.OfType<IPiechart>())

                  {

                      Console.WriteLine(" 2) Test - Type:{0} ID:{1}", child.Info.Type, child.Info.Id);

                  }

       

      //3) Test -   this code does not enter

                  foreach (ILinechart child in ASheet.Children.OfType<ILinechart>())

                  {

                      Console.WriteLine(" 3) Test - Type:{0} ID:{1}", child.Info.Type, child.Info.Id);

                  }

      //4) Test -

                foreach (IGenericObject child in ASheet.Children )

                 {

                      Console.WriteLine(" 4) Test Type:{0} ID:{1}", child.Type, child.Id);

                    

                  }

       

      Output:

       

      Test: Il mio nuovo foglio

      1) Test -  Type:table ID:sFq

      1) Test -  Type:piechart ID:FUyeBYF

      4) Test Type:GenericObject ID:sFq

      4) Test Type:GenericObject ID:FUyeBYF

      Test: Sheet2

      1) Test -  Type:linechart ID:LJHaM

      4) Test Type:GenericObject ID:LJHaM

       

       

      NB. Delphi solution with OCX

       

      procedure TXXX.GetSheetObjects(var ListObjectID: TStringlist;

        const AObjectType: array of Smallint; ADoc: TQlikDocument; ASheet: Sheet);

      var

        i, j: Integer;

        objs: OleVariant; // TSheetObjects;

        obj: SheetObject;

      begin

        if ASheet <> nil then

          try

            // ListObjectID:=TStringList.Create;

            if ASheet.Noofsheetobjects > 0 then

            begin

              objs := ASheet.GetSheetObjects;

              For i := VarArrayLowBound(objs, 1) to VarArrayHighBound(objs, 1) do

              begin

                obj := TSheetObjects(objs)[i];

                for j := 0 to High(AObjectType) do

                begin

                  if (obj as SheetObject).GetObjectType = AObjectType[j] then

                  begin

                    ListObjectID.Add((obj as SheetObject).GetObjectID);

                    break;

                  end;

                end;

              end;

       

       

            end;

          except

       

       

          end;

      end;

       

       

      PS

       

      Sorry if I insist with questions ... but there is the old function that performs GetSheetObjectbyID

      .........."ActiveDocument.GetSheetObject("CH06")"...........



      thank you in advance for your patience

      Corchi