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. Working with Excel Sheet?
Forum Updated to NodeBB v4.3 + New Features

Working with Excel Sheet?

Scheduled Pinned Locked Moved General and Desktop
17 Posts 7 Posters 43.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.
  • S Offline
    S Offline
    Skyrim
    wrote on last edited by
    #8

    As it turned out, run Excel macro knowing his name - very simple.

    @
    QString nameMacro = "mac"; //name macro
    excel->dynamicCall("Run(QVariant)", nameMacro);
    @

    1 Reply Last reply
    0
    • B Offline
      B Offline
      black_coder
      wrote on last edited by
      #9

      Anyone knows how to extract an attached images inside a cell using the excel activex ? I can read and write normal text but I can't manage to extract images attached inside a cell. Any help would be appreciated.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leninbooter
        wrote on last edited by
        #10

        [quote author="Skyrim" date="1307478863"]As it turned out, run Excel macro knowing his name - very simple.

        @
        QString nameMacro = "mac"; //name macro
        excel->dynamicCall("Run(QVariant)", nameMacro);
        @

        [/quote]

        Hello, I've been trying to make this work and just doesn't
        I can't find the mistake

        seleccion->dynamicCall("GoTo(const QString&, const QString&, const QString&)","wdGoToPage","wdGoToAbsolute", pag);
        

        I really would thank you very much if you can help me

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Skyrim
          wrote on last edited by
          #11

          Sorry but this does not apply to work with Excel Sheets, its work with Word Documents
          It would be nice to look at your code, because I do not understand what you are trying to do.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Skyrim
            wrote on last edited by
            #12

            ok, let it be Word
            for example, "go to" the 3 line.

            @
            word = new QAxObject("Word.Application", this);
            word->setProperty("DisplayAlerts", false);
            doc = word->querySubObject("Documents");
            doc->dynamicCall("Open(QVariant)", "d:\a15.doc");
            word->querySubObject("Selection")->querySubObject("GoTo(Int, Int, Int)", 3, 1, 3);
            @
            Selection.GoTo(What, Which, Count, Name)
            What:=wdGoToLine - emun = 3;
            Which:=wdGoToAbsolute - enum = 1;
            Count:= 3 - destination line
            -Name - forget about Name

            1 Reply Last reply
            0
            • L Offline
              L Offline
              leninbooter
              wrote on last edited by
              #13

              :-O OMG , dude, thank you very much... So, I have to use the correspoding number of the enumeration instead of the name of the enumeration (wdGoToLine) it works!!! thank you veryyyyyyyy
              Sorry for misplacing this but I thought this was the most related thread :P
              Thank you againnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Skyrim
                wrote on last edited by
                #14

                Come on,
                ... and welcome to the best qt forum

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  leninbooter
                  wrote on last edited by
                  #15

                  :P I'm sure it is :D

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    leninbooter
                    wrote on last edited by
                    #16

                    [quote author="Skyrim" date="1305238978"]Hi all
                    Error in row 9.
                    Should be:
                    @
                    QAxObject *worksheets = workbook->querySubObject("Sheets");
                    worksheets->dynamicCall("Add()"); //insert new Sheet
                    @

                    everything else was fine.[/quote]

                    Hi, was this running inside a qt dialog or window? or outside ur qt application?

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vsgobbi
                      wrote on last edited by
                      #17

                      Skyrim! Thanks for the tip. Works great!
                      I have to do the same thread, but comparing one row, which has a product description of my .xls file (as database) with bar code input by code bar reader of the software user.
                      I'm just adding this to my *.pro *Project File:

                      @CONFIG += qaxcontainer
                      DEF_FILE = qaxserver.def
                      RC_FILE = qaxserver.rc@

                      This on my .cpp file working with a new "QTableWidget":

                      @{
                      QAxObject *excel;
                      QAxObject *wbooks;
                      QAxObject *book;
                      QAxObject *sheets;
                      QAxObject *cell;
                      QTableWidgetItem *wit;

                      excel = new QAxObject("Excel.Application", this);
                      excel->setProperty("Visible", 1);
                      excel->setProperty("DisplayAlerts", 0);
                      wbooks = excel->querySubObject("Workbooks");
                      book = wbooks->querySubObject("Open (const QString&)", "C:\\1.xls" );;
                      sheets = book->querySubObject("Sheets");
                      ui->spinBox->setValue(sheets->dynamicCall("Count()").toInt());
                      
                      
                      for (int i = 0; i<ui->tableWidget->rowCount(); i++){
                          for (int j =0; j<ui->tableWidget->columnCount(); j++){
                              cell = excel->querySubObject("Cells(QVariant&, QVariant&)", i+1, j+1);
                              wit = new QTableWidgetItem(cell->property("Value()").toString());
                              wit = new QTableWidgetItem(QString("%1,%2").arg(i).arg(j));
                              ui->tableWidget->setRowCount(10);
                              ui->tableWidget->setColumnCount(5);
                              ui->tableWidget->setItem(i, j, wit);
                          }
                      }
                      
                      for (int i = 1; i <= 5; i++) {
                              for (int j = 1; j <= 3; j++) {
                                  cell = excel->querySubObject("Cells(Int, Int)", i, j);
                                  QString valC = cell->dynamicCall("value").toString();
                                  ui->textEdit->append(valC);//-- simple check
                                  QTableWidgetItem *it = new QTableWidgetItem;
                                  it->setText(valC);
                                  it->setText(cell->dynamicCall("Value").toString());
                      
                                  ui->tableWidget->setItem(i-1, j-1, it);
                                  ui->tableWidget->setRowCount(10);
                                  ui->tableWidget->setColumnCount(5);
                              }
                          }
                      

                      }
                      @


                      My code doesn't work! Don't know why.
                      My code works! Still don't know why...

                      1 Reply Last reply
                      0

                      • Login

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