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 read and wtrite the xls and xlsx files on the qt?are there any libs that could support these formats of files
Forum Updated to NodeBB v4.3 + New Features

how to read and wtrite the xls and xlsx files on the qt?are there any libs that could support these formats of files

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 6 Posters 770 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1

    how to read and wtrite the xls and xlsx files on the qt?are there any libs that could support these formats of files?dose the qt platform third-party libs want to do this?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I have not used that library by I think the QtXlsx project might be what you are looking for.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      nicker playerN 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        I have not used that library by I think the QtXlsx project might be what you are looking for.

        nicker playerN Offline
        nicker playerN Offline
        nicker player
        wrote on last edited by
        #3

        @SGaist
        the libs u just mentioned only support the xlsx format,but not for the xls format.I just want to use the qt to transform the xls file into the xlsx file.

        jsulmJ 1 Reply Last reply
        0
        • nicker playerN nicker player

          @SGaist
          the libs u just mentioned only support the xlsx format,but not for the xls format.I just want to use the qt to transform the xls file into the xlsx file.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @nicker-player Qt itself has no libraries to read/write Microsoft Office formats. You will need to search for third party libs.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          nicker playerN 1 Reply Last reply
          1
          • jsulmJ jsulm

            @nicker-player Qt itself has no libraries to read/write Microsoft Office formats. You will need to search for third party libs.

            nicker playerN Offline
            nicker playerN Offline
            nicker player
            wrote on last edited by
            #5

            @jsulm
            I knew that.I just wondered if anyone could offer me some useful advices.cause it is hard to find the useful libs.

            JonBJ 1 Reply Last reply
            0
            • nicker playerN nicker player

              @jsulm
              I knew that.I just wondered if anyone could offer me some useful advices.cause it is hard to find the useful libs.

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

              @nicker-player
              You asked this question in 2022 at https://forum.qt.io/topic/139394/how-to-read-write-the-files-with-the-ole-format-like-xls-xlsx-doc. Did you investigate the 3rd party .xls format readers listed at https://wiki.qt.io/Handling_Microsoft_Excel_file_format? I can't imagine there will be anything more up-to-date than that.

              One possibility, possibly your best while I think of it, would be to use Excel Automation to read in from .xls file and save back with .xlsx format? So Excel does the conversion for you. Some samples are in https://stackoverflow.com/questions/9918646/how-to-convert-xls-to-xlsx.

              There are also a few xls to xlsx converters online, some claiming to be free. No idea how good they are.

              nicker playerN 1 Reply Last reply
              1
              • JonBJ JonB

                @nicker-player
                You asked this question in 2022 at https://forum.qt.io/topic/139394/how-to-read-write-the-files-with-the-ole-format-like-xls-xlsx-doc. Did you investigate the 3rd party .xls format readers listed at https://wiki.qt.io/Handling_Microsoft_Excel_file_format? I can't imagine there will be anything more up-to-date than that.

                One possibility, possibly your best while I think of it, would be to use Excel Automation to read in from .xls file and save back with .xlsx format? So Excel does the conversion for you. Some samples are in https://stackoverflow.com/questions/9918646/how-to-convert-xls-to-xlsx.

                There are also a few xls to xlsx converters online, some claiming to be free. No idea how good they are.

                nicker playerN Offline
                nicker playerN Offline
                nicker player
                wrote on last edited by
                #7

                @JonB
                thanks a lot.the topic u just mentioned is very useful.thanks a lot.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SimonSchroeder
                  wrote on last edited by
                  #8

                  I believe you can use OpenOffice/LibreOffice as a library. However, I personally never wanted to have such a huge library in my project.

                  nicker playerN 1 Reply Last reply
                  0
                  • S SimonSchroeder

                    I believe you can use OpenOffice/LibreOffice as a library. However, I personally never wanted to have such a huge library in my project.

                    nicker playerN Offline
                    nicker playerN Offline
                    nicker player
                    wrote on last edited by
                    #9

                    @SimonSchroeder
                    I agreed that.and in fact its too hard for me to compile the libs into my project. it is too hard.I just want a lib could trans the xls into the xlsx file.but the topics above is too complex for me.

                    JonBJ 1 Reply Last reply
                    0
                    • nicker playerN nicker player

                      @SimonSchroeder
                      I agreed that.and in fact its too hard for me to compile the libs into my project. it is too hard.I just want a lib could trans the xls into the xlsx file.but the topics above is too complex for me.

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

                      @nicker-player
                      I looked years ago at using OpenOffice/LibreOffice as a library, and it is way too large and complicated.

                      Since we seem to have established there is no "lib" already written to translate between the formats, by now you could have used the Qt ActiveX integration to do the necessary loading and saving to convert.

                      nicker playerN 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @nicker-player
                        I looked years ago at using OpenOffice/LibreOffice as a library, and it is way too large and complicated.

                        Since we seem to have established there is no "lib" already written to translate between the formats, by now you could have used the Qt ActiveX integration to do the necessary loading and saving to convert.

                        nicker playerN Offline
                        nicker playerN Offline
                        nicker player
                        wrote on last edited by
                        #11

                        @JonB
                        Ive tried what u just mentioned.but it failed caused I call these codes before the qApp was inited.
                        some one said that I should do something before new the QAxObject.I dont know what should do to fix it.

                        HRESULT r = OleInitialize(0);
                         if (r != S_OK && r != S_FALSE){...}
                        QAxObject* excel = new QAxObject();
                        t_ctrl_state = excel->setControl("Excel.Application");   
                        

                        it occured that:
                        CoCreateInstance failure
                        QAxBase::setControl: requested control Excel.Application could not be instantiated

                        jsulmJ C 2 Replies Last reply
                        0
                        • nicker playerN nicker player

                          @JonB
                          Ive tried what u just mentioned.but it failed caused I call these codes before the qApp was inited.
                          some one said that I should do something before new the QAxObject.I dont know what should do to fix it.

                          HRESULT r = OleInitialize(0);
                           if (r != S_OK && r != S_FALSE){...}
                          QAxObject* excel = new QAxObject();
                          t_ctrl_state = excel->setControl("Excel.Application");   
                          

                          it occured that:
                          CoCreateInstance failure
                          QAxBase::setControl: requested control Excel.Application could not be instantiated

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @nicker-player said in how to read and wtrite the xls and xlsx files on the qt?are there any libs that could support these formats of files:

                          but it failed caused I call these codes before the qApp was inited

                          Then do it after QApplication initialization.
                          QAxObject is a QObject and QObjects require QApplication instance.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          1
                          • nicker playerN Offline
                            nicker playerN Offline
                            nicker player
                            wrote on last edited by
                            #13

                            but if that.what should i do to call this in a std:: thread .dose the qloop would fail?

                            jsulmJ 1 Reply Last reply
                            0
                            • nicker playerN nicker player

                              but if that.what should i do to call this in a std:: thread .dose the qloop would fail?

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              @nicker-player Sorry, I don't know what you mean. Why do you need a thread?

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • nicker playerN nicker player

                                @JonB
                                Ive tried what u just mentioned.but it failed caused I call these codes before the qApp was inited.
                                some one said that I should do something before new the QAxObject.I dont know what should do to fix it.

                                HRESULT r = OleInitialize(0);
                                 if (r != S_OK && r != S_FALSE){...}
                                QAxObject* excel = new QAxObject();
                                t_ctrl_state = excel->setControl("Excel.Application");   
                                

                                it occured that:
                                CoCreateInstance failure
                                QAxBase::setControl: requested control Excel.Application could not be instantiated

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

                                @nicker-player said in how to read and wtrite the xls and xlsx files on the qt?are there any libs that could support these formats of files:

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

                                Is Excel installed on the machine you are running this on?

                                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