Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to read & write the files with the ole format like xls,xlsx,doc?
Qt 6.12 LTS is out! See what's new in the release blog

How to read & write the files with the ole format like xls,xlsx,doc?

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

    OS:win & linux,compile tools: best for the mingw32
    Now the project need to read and write the xls or xlsx files and so on.
    When i looked for the methods to solve the problem,Its hard to find an efficiently way.
    Are there any modules or dlls to read and write these files?

    Here's the way i thought was not useful.

    1.Use the activex or com compenent, need the target platform to install the office software.

    2.Use the third plugins of the office,could not find an project which is open source and easy to use.Some liked libxls,xlnt doesnt work well. In the fact that I have tried all of them on the internet what I could searched out,including the libre office which was hard to compile the minimal dlls of the xls or xlsx module.

    3.Use the java or python module by the socket server ,very complex and huge codes.
    If the net was breaked or the server was closed,It couldnt work anymore.
    There are the modules of the xls file or some thing else in the python or java envirment.Why qt doesnt have one? python is based on the c platform.

    4.Use the odbc or some db software.I dont think its a good idea,so slowly and always get errors at runtime.

    So could anyone tell me about how to solve the problem?
    If there's an useful dll or modules.

    JonBJ 1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      The old Excel and Word format files (typically .XLS and .DOC) are proprietary OLE compound object binary formats and no longer the default formats for these applications. They are documented, but it would a be big job to handle these directly.

      The current Excel and Word formats (typically .XSLX and .DOCX) are compressed (zip file) collections of an XML based format. These are notionally easier to manipulate and probably easier to find third party libraries.

      See Handling Microsoft Excel file format in the Qt Wiki for some options.

      If a customer is asking me for input/output in Word/Excel then I would think it likely that they have the relevant programs and that ActiveQt will provide an access path with close to complete functionality. The ODBC option can make sense for Excel (not Word).

      1 Reply Last reply
      2
      • nicker playerN nicker player

        OS:win & linux,compile tools: best for the mingw32
        Now the project need to read and write the xls or xlsx files and so on.
        When i looked for the methods to solve the problem,Its hard to find an efficiently way.
        Are there any modules or dlls to read and write these files?

        Here's the way i thought was not useful.

        1.Use the activex or com compenent, need the target platform to install the office software.

        2.Use the third plugins of the office,could not find an project which is open source and easy to use.Some liked libxls,xlnt doesnt work well. In the fact that I have tried all of them on the internet what I could searched out,including the libre office which was hard to compile the minimal dlls of the xls or xlsx module.

        3.Use the java or python module by the socket server ,very complex and huge codes.
        If the net was breaked or the server was closed,It couldnt work anymore.
        There are the modules of the xls file or some thing else in the python or java envirment.Why qt doesnt have one? python is based on the c platform.

        4.Use the odbc or some db software.I dont think its a good idea,so slowly and always get errors at runtime.

        So could anyone tell me about how to solve the problem?
        If there's an useful dll or modules.

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

        @nicker-player
        For .xlsx there is QXlsx, which I know some people are using.

        For .docx I'm not so sure there is anything around. Read through the thread including https://forum.qt.io/topic/127193/how-to-open-and-edit-the-doc-or-docx-file-in-qt/7. Note as I wrote that if you use ActiveX/COM components (QAx...) that automatically means it won't work under Linux.

        Also as I wrote there

        A docx file is basically a zipped file containing XML.

        Same applies for xlsx file. You can examine the XML by unzipping the files, and you could even have a go at trying to read/write them with Qt QXmlStreamReader/Writer, but not sure how well that would work or where you would get with that.

        1 Reply Last reply
        1
        • JonBJ JonB referenced this topic on

        • Login

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