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. Extracting graphics from Excel?

Extracting graphics from Excel?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.9k Views
  • 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.
  • M Offline
    M Offline
    meepo1
    wrote on last edited by meepo1
    #1

    How can I do it. This way for example can get values (text and numbers)from Excel

    
    QAxObject* excel     = new QAxObject("Excel.Application");
    QAxObject* workbooks = excel->querySubObject("Workbooks");
    QAxObject* workbook  = workbooks->querySubObject("Open(const QString&)","c:\\temp\\i1.xlsx");
    QAxObject* sheets    = workbook->querySubObject("Worksheets");
    QAxObject* sheet     = sheets->querySubObject("Item(int)", 1);
    excel->dynamicCall("ScreenUpdating()", false);
    i = 0;
    for (int f = 2; f <= 80; ++f){
        p = 0;
        for(int c = 2; c <= 11; ++c){
            auto cCell = sheet->querySubObject("Cells(int,int)",f,c);
            if(cCell->dynamicCall("Value()").value<int>() == NULL){
               if(c == 2){
                  a = cCell->dynamicCall("Value()").toString();
                  p +=  1;
               }else if(c == 4){
                  d = cCell->dynamicCall("Value()").toString();
                  p +=  1;
               }
            }
        }
    }
    excel->dynamicCall("Quit()");
    excel->dynamicCall("DisplayAlerts", false);
    delete excel;
    

    However, i want to pictures or statistical graphics

    E 1 Reply Last reply
    0
    • M meepo1

      How can I do it. This way for example can get values (text and numbers)from Excel

      
      QAxObject* excel     = new QAxObject("Excel.Application");
      QAxObject* workbooks = excel->querySubObject("Workbooks");
      QAxObject* workbook  = workbooks->querySubObject("Open(const QString&)","c:\\temp\\i1.xlsx");
      QAxObject* sheets    = workbook->querySubObject("Worksheets");
      QAxObject* sheet     = sheets->querySubObject("Item(int)", 1);
      excel->dynamicCall("ScreenUpdating()", false);
      i = 0;
      for (int f = 2; f <= 80; ++f){
          p = 0;
          for(int c = 2; c <= 11; ++c){
              auto cCell = sheet->querySubObject("Cells(int,int)",f,c);
              if(cCell->dynamicCall("Value()").value<int>() == NULL){
                 if(c == 2){
                    a = cCell->dynamicCall("Value()").toString();
                    p +=  1;
                 }else if(c == 4){
                    d = cCell->dynamicCall("Value()").toString();
                    p +=  1;
                 }
              }
          }
      }
      excel->dynamicCall("Quit()");
      excel->dynamicCall("DisplayAlerts", false);
      delete excel;
      

      However, i want to pictures or statistical graphics

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @meepo1 Maybe you should ask help from a Microsoft/Office oriented forum. Your question has nothing to do with Qt.

      M 1 Reply Last reply
      -1
      • E Eeli K

        @meepo1 Maybe you should ask help from a Microsoft/Office oriented forum. Your question has nothing to do with Qt.

        M Offline
        M Offline
        meepo1
        wrote on last edited by meepo1
        #3

        @Eeli-K there are other threads that ask about Excel in this forum and i've never seen any reply that says the same as you.
        PS: In addition, where can i find QAXOBJECT out of this forum

        E 1 Reply Last reply
        0
        • M meepo1

          @Eeli-K there are other threads that ask about Excel in this forum and i've never seen any reply that says the same as you.
          PS: In addition, where can i find QAXOBJECT out of this forum

          E Offline
          E Offline
          Eeli K
          wrote on last edited by
          #4

          @meepo1 Sorry, I misread the class name, QAxObject is really a Qt class and the question was appropriate. But it still requires non-Qt expertise so you may not be lucky here. It's a COM wrapper and agnostic about the commands. You could ask about it in stackoverflow or some MS/COM related forum. Someone can of course know and answer here, even if a question was not Qt related.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            patrik08
            wrote on last edited by patrik08
            #5

            Rename the excel file as zip...
            extract image like xml .. close all.
            rename back...
            or zip reader from QT..
            https://github.com/pehohlva/DocSpeacker/blob/master/src/st_lib/gzipreader.h

            https://stackoverflow.com/questions/11082278/how-to-properly-assemble-a-valid-xlsx-file-from-its-internal-sub-components

            other way...
            the best to have a sample to build qt Component..
            https://github.com/dbzhang800/QtXlsxWriter

            Documentation: http://qtxlsx.debao.me

            QtXlsx is a library that can read and write Excel files. It doesn't require Microsoft Excel and can be used in any platform that Qt5 supported. The library can be used to

            Generate a new .xlsx file from scratch
            Extract data from an existing .xlsx file
            Edit an existing .xlsx file
            Getting Started

            For linux user, if your Qt is installed through package manager tools such "apt-get", make sure that you have installed the Qt5 develop package qtbase5-private-dev
            Usage(1): Use Xlsx as Qt5's addon module

            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