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. Why export excel in windows10 normal, in windows7 export will crash?
Forum Updated to NodeBB v4.3 + New Features

Why export excel in windows10 normal, in windows7 export will crash?

Scheduled Pinned Locked Moved Solved General and Desktop
24 Posts 5 Posters 4.1k 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.
  • mrjjM mrjj

    @duncan98
    Is it same excel version?
    My guess would be on that so some of the calls fails and then being used.

    Can you debug it on win 7 32 bit ?

    else you need to use other methods to find out WHERE it crashes, in which line.

    D Offline
    D Offline
    duncan98
    wrote on last edited by
    #5

    @mrjj
    I mean, excel crashed when I was trying to save it. It's not open yet

    mrjjM 1 Reply Last reply
    0
    • D duncan98

      @mrjj
      I mean, excel crashed when I was trying to save it. It's not open yet

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #6

      @duncan98
      you mean this part ?
      QString file_path=QFileDialog::getSaveFileName(nullptr,"save file",file_name,"(.xlsx);;(.xls);;(*.csv)");

      D 1 Reply Last reply
      0
      • mrjjM mrjj

        @duncan98
        you mean this part ?
        QString file_path=QFileDialog::getSaveFileName(nullptr,"save file",file_name,"(.xlsx);;(.xls);;(*.csv)");

        D Offline
        D Offline
        duncan98
        wrote on last edited by
        #7

        @mrjj
        In debugging, I found the same code that workbooks created in windows10 but not in windows7
        c.jpg c2.jpg

        JonBJ M 2 Replies Last reply
        0
        • D duncan98

          @mrjj
          In debugging, I found the same code that workbooks created in windows10 but not in windows7
          c.jpg c2.jpg

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #8

          @duncan98
          Since QAxObject is only a thin layer over accessing ActiveX objects, I would look in the Excel VBA model for differences rather than in Qt. Did you try your code from within Excel macros/VBA to see how it works quite outside Qt?

          D 1 Reply Last reply
          2
          • JonBJ JonB

            @duncan98
            Since QAxObject is only a thin layer over accessing ActiveX objects, I would look in the Excel VBA model for differences rather than in Qt. Did you try your code from within Excel macros/VBA to see how it works quite outside Qt?

            D Offline
            D Offline
            duncan98
            wrote on last edited by
            #9

            @JonB
            I have checked that the vba syntax is correct, otherwise it will not succeed in windows10, but I don't know if other components are needed in windows7

            1 Reply Last reply
            0
            • D Offline
              D Offline
              duncan98
              wrote on last edited by
              #10

              The application output shows:
              QAxBase::setControl: requested control Excel.Application could not be instantiated
              QAxBase::dynamicCallHelper: Object is not initialized, or initialization failed

              JonBJ 1 Reply Last reply
              0
              • D duncan98

                The application output shows:
                QAxBase::setControl: requested control Excel.Application could not be instantiated
                QAxBase::dynamicCallHelper: Object is not initialized, or initialization failed

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #11

                @duncan98 said in Why export excel in windows10 normal, in windows7 export will crash?:

                QAxBase::setControl: requested control Excel.Application could not be instantiated

                This is the error message which matters. It indicates Excel.Application could not be instantiated.

                You can Google for QAxBase::setControl: requested control Excel.Application could not be instantiated to see others reporting similar. One suggestion is:

                The control requested in QAxBase::setControl() is not installed on this system, or is not accessible for the current user.

                The control might require administrator rights, or a license key. If the control is licensed, pass the license key to QAxBase::setControl as documented.

                Your issue seems to be reported in https://stackoverflow.com/questions/67901747/qaxwidget-is-in-use-and-an-error-occurs-when-reading-excel-in-qt-creator, I don't know whether you are the author of that question.

                One small thought is: how do you create/what kind of Qt application?

                You might try finding and passing the desired GUID/CLSID in place of Excel.Application, just in case.

                I believe PowerShell allows you to do Automation? I would try that, or something similar, to verify you can connect successfully from a non-Qt application on the failing machine.

                D 1 Reply Last reply
                3
                • JonBJ JonB

                  @duncan98 said in Why export excel in windows10 normal, in windows7 export will crash?:

                  QAxBase::setControl: requested control Excel.Application could not be instantiated

                  This is the error message which matters. It indicates Excel.Application could not be instantiated.

                  You can Google for QAxBase::setControl: requested control Excel.Application could not be instantiated to see others reporting similar. One suggestion is:

                  The control requested in QAxBase::setControl() is not installed on this system, or is not accessible for the current user.

                  The control might require administrator rights, or a license key. If the control is licensed, pass the license key to QAxBase::setControl as documented.

                  Your issue seems to be reported in https://stackoverflow.com/questions/67901747/qaxwidget-is-in-use-and-an-error-occurs-when-reading-excel-in-qt-creator, I don't know whether you are the author of that question.

                  One small thought is: how do you create/what kind of Qt application?

                  You might try finding and passing the desired GUID/CLSID in place of Excel.Application, just in case.

                  I believe PowerShell allows you to do Automation? I would try that, or something similar, to verify you can connect successfully from a non-Qt application on the failing machine.

                  D Offline
                  D Offline
                  duncan98
                  wrote on last edited by
                  #12

                  @JonB
                  The problem has been found. However, it cannot be initialized without software installed, which is more limited

                  mrjjM 1 Reply Last reply
                  0
                  • D duncan98

                    @JonB
                    The problem has been found. However, it cannot be initialized without software installed, which is more limited

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #13

                    @duncan98
                    So the reason it was not working was that you did not have excel installed ?

                    D 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @duncan98
                      So the reason it was not working was that you did not have excel installed ?

                      D Offline
                      D Offline
                      duncan98
                      wrote on last edited by
                      #14

                      @mrjj
                      Yes, this problem is very strange. You must install Microsoft Excel, but you can't install other Excel software

                      mrjjM JonBJ 2 Replies Last reply
                      0
                      • D duncan98

                        @mrjj
                        Yes, this problem is very strange. You must install Microsoft Excel, but you can't install other Excel software

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #15

                        @duncan98
                        Well its clear it needs Excel.
                        But what do you mean by
                        "l, but you can't install other Excel software"

                        You mean rest of the office or what other software ?

                        D 1 Reply Last reply
                        0
                        • mrjjM mrjj

                          @duncan98
                          Well its clear it needs Excel.
                          But what do you mean by
                          "l, but you can't install other Excel software"

                          You mean rest of the office or what other software ?

                          D Offline
                          D Offline
                          duncan98
                          wrote on last edited by duncan98
                          #16

                          @mrjj
                          I mean you can't initialize it with any other Excel processor installed.
                          Can you take a look at this for me? Thank you
                          https://forum.qt.io/topic/128391

                          mrjjM 1 Reply Last reply
                          0
                          • D duncan98

                            @mrjj
                            I mean you can't initialize it with any other Excel processor installed.
                            Can you take a look at this for me? Thank you
                            https://forum.qt.io/topic/128391

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #17

                            @duncan98
                            So you mean with another version of Excel installed, the same code no longer works?

                            D 1 Reply Last reply
                            0
                            • mrjjM mrjj

                              @duncan98
                              So you mean with another version of Excel installed, the same code no longer works?

                              D Offline
                              D Offline
                              duncan98
                              wrote on last edited by
                              #18

                              @mrjj
                              I haven't tried this

                              mrjjM 1 Reply Last reply
                              0
                              • D duncan98

                                @mrjj
                                I haven't tried this

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #19

                                @duncan98
                                Ehh
                                So what did you mena by "I mean you can't initialize it with any other Excel processor installed."

                                • other Excel processor = `????
                                1 Reply Last reply
                                0
                                • D duncan98

                                  @mrjj
                                  Yes, this problem is very strange. You must install Microsoft Excel, but you can't install other Excel software

                                  JonBJ Offline
                                  JonBJ Offline
                                  JonB
                                  wrote on last edited by
                                  #20

                                  @duncan98 said in Why export excel in windows10 normal, in windows7 export will crash?:

                                  Yes, this problem is very strange. You must install Microsoft Excel

                                  To use ActiveX of course you have to have the target application installed! It would help if you had mentioned this, the problem has nothing to do with Windows 7 vs Windows 10 and would have shown up if you had tried communicating with it from any other non-Qt application, as I suggested you do.

                                  D 1 Reply Last reply
                                  2
                                  • JonBJ JonB

                                    @duncan98 said in Why export excel in windows10 normal, in windows7 export will crash?:

                                    Yes, this problem is very strange. You must install Microsoft Excel

                                    To use ActiveX of course you have to have the target application installed! It would help if you had mentioned this, the problem has nothing to do with Windows 7 vs Windows 10 and would have shown up if you had tried communicating with it from any other non-Qt application, as I suggested you do.

                                    D Offline
                                    D Offline
                                    duncan98
                                    wrote on last edited by duncan98
                                    #21

                                    @JonB
                                    Can this Excel component be referenced independently? I want to package it into the installer

                                    JonBJ C 2 Replies Last reply
                                    0
                                    • D duncan98

                                      @JonB
                                      Can this Excel component be referenced independently? I want to package it into the installer

                                      JonBJ Offline
                                      JonBJ Offline
                                      JonB
                                      wrote on last edited by
                                      #22

                                      @duncan98
                                      What Excel component? What "referenced independently"?

                                      If you want to use ActiveX/Automation you need Excel on the target machine. You can't give your end users/distribute Excel, they need to install it themselves.

                                      1 Reply Last reply
                                      1
                                      • D duncan98

                                        @JonB
                                        Can this Excel component be referenced independently? I want to package it into the installer

                                        C Offline
                                        C Offline
                                        ChrisW67
                                        wrote on last edited by
                                        #23

                                        @duncan98 said in Why export excel in windows10 normal, in windows7 export will crash?:

                                        Can this Excel component be referenced independently? I want to package it into the installer

                                        The "Excel component" is called Microsoft Excel. I am sure that Microsoft will allow you to bundle a copy of Microsoft Excel inside your application if you send them enough legal paperwork and money ;)

                                        There are other ways to generate a file that Microsoft Excel, or another spreadsheet program, can open. These range from writing simple CSV files to OpenDocument or Office Open format XML. There are also some third-party libraries that can generate these formats (or subsets) or the older XLS. What will work for you depends on the end goal.

                                        1 Reply Last reply
                                        2
                                        • D duncan98

                                          @mrjj
                                          In debugging, I found the same code that workbooks created in windows10 but not in windows7
                                          c.jpg c2.jpg

                                          M Offline
                                          M Offline
                                          m.hosseini
                                          wrote on last edited by
                                          #24

                                          @duncan98
                                          At the frist make sure that your office excel is activated then use
                                          CoInitialize(nullptr);
                                          befire taking export.
                                          this function can find in #include <objbase.h>

                                          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