Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to pass array objects to QAxObject property (Excel)? [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

How to pass array objects to QAxObject property (Excel)? [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amahta
    wrote on 17 Feb 2014, 12:43 last edited by
    #1

    To be specific, I'm trying to set an Excel.Range.Value property using a QVariantList but all the time I get the same values in all of the cells inside Excel sheet. It only takes the first item out of my QVariantList and fills all of the cells with that same value.

    Any ideas?

    Thou shalt programme
    http://www.amin-ahmadi.com

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chris17
      wrote on 18 Feb 2014, 14:56 last edited by
      #2

      You have to create a QVariant, which is actually a QList<QList<QVariant> >

      I did it the following way:
      @
      QStringList row1;
      row1<<"asdf"<<"asdf";
      QList<QVariant> varlist;
      varlist.append(QVariant(row1));

      xls.selectRange(1,1, rowCount, columnCount);
      xls.setValue(QVariant(varlist);
      @

      1 Reply Last reply
      0
      • A Offline
        A Offline
        amahta
        wrote on 19 Feb 2014, 09:04 last edited by
        #3

        Wow it worked! Thanks for this GREAT tip :) Owe you a beer.
        In my case it was a column instead of row so I did something like this:
        @
        QVariantList varlist;
        for(.. some loop ..)
        {
        // do things
        QStringList item;
        item << someItem;
        varlist.append(item);
        }

        and later on ...

        excel.setValue(QVariant(varlist));
        @
        I assume the same method can be used for ranges with diff with and height.

        Thou shalt programme
        http://www.amin-ahmadi.com

        1 Reply Last reply
        0

        3/3

        19 Feb 2014, 09:04

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved