Graphics

 View Only
Expand all | Collapse all

Datalinq from excel document: Dynamically changing which sheet to get data

  • 1.  Datalinq from excel document: Dynamically changing which sheet to get data

    Posted 09-12-2017 12:43
    I am using a ADODB Datalinq to connect to a .xls-document using the Excel (Mixed Numeric/Text Data) template.
    In this file I have different sheets with different data, but all the sheets are similar in structure.

    What I would like is to dynamically, using a dropdown, adjust the sheet datalinq uses to fetch the data. My option, as I can see it now, is to add the scene multiple times in the sequence and just manually change every (30+) data element manually. Otherwise I can code it manually I guess. If that's my only option does anyone have any example datalinq code I could base it on?

    What I'm trying to output is a table with scores.

    Thanks.


  • 2.  RE: Datalinq from excel document: Dynamically changing which sheet to get data

    Posted 08-21-2018 19:06
    There is a workaround to do this...

    Don't update your Datalinq Key directly.

    Put your list in a text object, with your list as the data source for that object. Then, use a script on your scene object to modify the Datalinq Key:

    '===================================== THE SCRIPT:

    dim key as xpdatalinqkey
    dim keys as xpdatalinqkeys
    dim txt as xptextobject

    self.getobjectbyname("TEXT OBJECT NAME", txt)
    self.getdatalinqkeys(keys)
    keys.getkeybyname("DATALINQ KEY NAME", key)
    key.asstring = txt.text

    self.refreshdatalinqs

    '======END OF SCRIPT

    In your Data Source, set your Column to match what you want to select (AGE in the below example), and set your row to 1.
    Then use something like this as a query in Table:

    SELECT [AGE] FROM [%TRI1%$] WHERE [PLAYER] = '%PLAYERNUM%'

    Then, you can set your PLAYERNUM datalinq to be %relid% if you want to use a row number in a group, or you can type the player number directly into that Datalinq.

    Hope that helps!
    #XPression