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. Qt and Excell file
Forum Update on Tuesday, May 27th 2025

Qt and Excell file

Scheduled Pinned Locked Moved Solved General and Desktop
excel
6 Posts 3 Posters 991 Views 2 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.
  • B Offline
    B Offline
    Babs
    wrote on last edited by
    #1

    Hello,
    Is there any Qt feature allowing to work efficiently with Excel format files ( read, write , extraction...) ?

    J.HilkJ 1 Reply Last reply
    0
    • B Babs

      Hello,
      Is there any Qt feature allowing to work efficiently with Excel format files ( read, write , extraction...) ?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Babs you can use QSql (to a certain degree) or Qt's ActiveX framework

      the wiki has an example:
      https://wiki.qt.io/Handling_Microsoft_Excel_file_format


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      B 1 Reply Last reply
      3
      • J.HilkJ J.Hilk

        @Babs you can use QSql (to a certain degree) or Qt's ActiveX framework

        the wiki has an example:
        https://wiki.qt.io/Handling_Microsoft_Excel_file_format

        B Offline
        B Offline
        Babs
        wrote on last edited by
        #3

        @J-Hilk thanks

        B 1 Reply Last reply
        0
        • B Babs

          @J-Hilk thanks

          B Offline
          B Offline
          Babs
          wrote on last edited by
          #4

          @Babs I've got the following when i use the Qt's ActiveX framework

              QCoreApplication app(argc,argv);
              QAxObject* excel = new QAxObject( "Excel.Application");
              qDebug()<<"jere";
              QAxObject* workbooks = excel->querySubObject( "Workbooks" );
              /*QAxObject* workbook = workbooks->querySubObject( "Open(const QString&)", "C:\\Program Files (x86)\\MILESYS\\SacemSol\\secteur_11\\resultat\\20200728_161431RERA_S11.xlsx" );
              QAxObject* sheets = workbook->querySubObject( "Worksheets" );
              QList<QVariantList> data; //Data list from excel, each QVariantList is worksheet row
          
              //worksheets count
              int count = sheets->dynamicCall("Count()").toInt();
              qDebug()<<count;*/
          
          
          
          
              return app.exec();
          

          I've got this error after launching:

          QAxBase::setControl: requested control Excel.Application could not be instantiated
          jere
          QAxBase::dynamicCallHelper: Object is not initialized, or initialization failed
          
          
          mrjjM 1 Reply Last reply
          0
          • B Babs

            @Babs I've got the following when i use the Qt's ActiveX framework

                QCoreApplication app(argc,argv);
                QAxObject* excel = new QAxObject( "Excel.Application");
                qDebug()<<"jere";
                QAxObject* workbooks = excel->querySubObject( "Workbooks" );
                /*QAxObject* workbook = workbooks->querySubObject( "Open(const QString&)", "C:\\Program Files (x86)\\MILESYS\\SacemSol\\secteur_11\\resultat\\20200728_161431RERA_S11.xlsx" );
                QAxObject* sheets = workbook->querySubObject( "Worksheets" );
                QList<QVariantList> data; //Data list from excel, each QVariantList is worksheet row
            
                //worksheets count
                int count = sheets->dynamicCall("Count()").toInt();
                qDebug()<<count;*/
            
            
            
            
                return app.exec();
            

            I've got this error after launching:

            QAxBase::setControl: requested control Excel.Application could not be instantiated
            jere
            QAxBase::dynamicCallHelper: Object is not initialized, or initialization failed
            
            
            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            @Babs
            Hi
            You do have Excel installed, right ?

            There is also
            https://github.com/dbzhang800/QtXlsxWriter
            http://qtxlsx.debao.me/

            Also see here
            https://forum.qt.io/topic/89536/qaxobject-and-excel/3
            use QApplication a(argc, argv); instead of QCoreApplication app(argc,argv);

            Ahh should work.

            B 1 Reply Last reply
            4
            • mrjjM mrjj

              @Babs
              Hi
              You do have Excel installed, right ?

              There is also
              https://github.com/dbzhang800/QtXlsxWriter
              http://qtxlsx.debao.me/

              Also see here
              https://forum.qt.io/topic/89536/qaxobject-and-excel/3
              use QApplication a(argc, argv); instead of QCoreApplication app(argc,argv);

              Ahh should work.

              B Offline
              B Offline
              Babs
              wrote on last edited by
              #6

              @mrjj thanks

              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