Generate of txt or csv or xls file with variable name

 
  • I have created a macro which list elements with some atts and desp from a zone or a site and I try to generate an excel file with the name of the zone or the site to output this list.

    How I can make this ?

    Thanks
  • do !branchMember values !branchMembers
       if !branchMember.type.eq('TUBI') then
           !col[1] = !branchMember.itle
       else
           !col[1] = !branchMember.brwei
       endif
       .
       .
       .
       .
    enddo
  • [QUOTE=h3nrik;109309]do !branchMember values !branchMembers
       if !branchMember.type.eq('TUBI') then
           !col[1] = !branchMember.itle
       else
           !col[1] = !branchMember.brwei
       endif
       .
       .
       .
       .
    enddo

    Hello h3nrik,


    problem is I'm using something different, and my question was wrong, I was asking about the IF statement in !headings[].

    ----------------Initialise -------
    define method .refresh()


    -- HEADINGS DEFINITION -----------


    !headings    = ARRAY()
      !headings[1] = 'NAMN'
      !headings[2] = 'TYPE'
      !headings[3] = ':PFCUTLENGTH'
      !headings[4] = 'SPREF'
      !headings[5] = ':material_id of prtref of spref'
      !headings = 'NWEI'
      !headings[7] = 'PCRFA'
     
      !AttColumns    = ARRAY()
      !AttColumns[1] = 'Name'
      !AttColumns[2] = 'Type'
      !AttColumns[3] = 'Length'
      !AttColumns[4] = 'Spref'
      !AttColumns[5] = 'Ident'
      !AttColumns = 'Weight'
      !AttColumns[7] = 'Pspool'
    -- Create model items for population of grid
    !PspoolList = object ARRAY()
    !PspoolElements = object ARRAY()
    !sve = object ARRAY()
    !ASMBLY = ce
    IF (!ASMBLY.type neq |ASMBLY|) then
    !!Alert.Message('CE not ASSY, You need to be on Assembly to use the form')
    !this.grid.clearGrid()
    else
    ---COLLECTING ALL PSPOOL FROM DESIGN THREE------------------
    var !PspoolCollect collect all (PSPOOL) for CE
    do !Pspool values !PspoolCollect
    IF (!pspool.dbref().type eq 'PSPOOL') THEN
    !PspoolList.Append(!Pspool.DBREF().name)
    ELSE
    ENDIF
    enddo
    ---COLLECTING IN ARRAY ALL THE MEMBERS FROM PSPOOL----------
    do !i values !PspoolList
    !PspoolElements.Append(!i.DBREF().MELRFA)
    enddo
    DO !J INDICES !pspoolelements
    do !k values !pspoolelements[$!j]
     !sve.Append(!k.name)
    enddo
    enddo
    ENDIF
      -- Bind data to grid
      using namespace  'Aveva.Pdms.Presentation'
      !nds = object NetDataSource('Grid Control Example', !headings, !attColumns, !sve)
      !this.grid.BindToDataSource(!nds)


      -- Set grid parameters
    endmethod
  • Sorry. I do not follow the question now.
    Do you want different headings at the same time? Or different values for the same heading?
  • [QUOTE=h3nrik;109423]Sorry. I do not follow the question now.
    Do you want different headings at the same time? Or different values for the same heading?

    Hello, since I want to have excel export file of all pspool members I would like to use syntax like this:

    [COLOR=#333333]if !sve.type.eq('TUBI') then[/COLOR]
    [COLOR=#333333]!headings = 'itle'[/COLOR]
    [COLOR=#333333]else[/COLOR]
    [COLOR=#333333]!headings = 'nwei'[/COLOR]
    [COLOR=#333333]endif

    But I have tried this and no luck its always reading the first condidtion. So column rows are filled only with ITLE.

    Thanks in advance!

    I'll try to use me_hungry concept and see the results.
    [/COLOR]
  • Ok. I understand.
    Yes, you need to follow me_hungry's instructions and store the values you want to present in the grid as an array of arrays

    Like:
    [COLOR=#0000cd]!array.Append(!col)[/COLOR][COLOR=#333333][COLOR=#008000]

    [/COLOR][/COLOR]But he has a type at the end
    [COLOR=#0000cd]!grid.bindToDataSource[/COLOR][COLOR=#333333][COLOR=#008000][COLOR=#333333][COLOR=#008000]([/COLOR][/COLOR][/COLOR][/COLOR]object NETDATASOURCE[COLOR=#333333][COLOR=#008000][COLOR=#333333][COLOR=#008000]([/COLOR][/COLOR][/COLOR][/COLOR][COLOR=#0000cd]!title, !header, !col[/COLOR]))[COLOR=#333333][COLOR=#008000][COLOR=#333333][COLOR=#008000]
    [/COLOR][/COLOR][/COLOR][/COLOR]Should be
    [COLOR=#0000cd]!grid.bindToDataSource[/COLOR][COLOR=#333333][COLOR=#008000]([/COLOR][/COLOR]object NETDATASOURCE[COLOR=#333333][COLOR=#008000]([/COLOR][/COLOR][COLOR=#0000cd]!title, !header, !array[/COLOR]))[COLOR=#333333][COLOR=#008000]
    [/COLOR][/COLOR]as you want to display the array that has other arrays as members, one for each row

    In your last example, you bind with:
    [COLOR=#0000cd]!nds[/COLOR] = object NetDataSource([COLOR=#008000]'Grid Control Example'[/COLOR], [COLOR=#0000cd]!headings, !attColumns, !sve[/COLOR])[COLOR=#333333][COLOR=#008000]
    [/COLOR][/COLOR]Telling the grid to use the array of attributes and go and get the values of those attributes from the list of elements in !sve array. Doing it like that you cannot mix different attributes.
  • Dear Rokotwo

    Can you please share the form to get this result?