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. Export QTableView to Excel file

Export QTableView to Excel file

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 2.0k 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.
  • lincolnL Offline
    lincolnL Offline
    lincoln
    wrote on last edited by
    #1

    hello friends, i have a query about a QTableView.
    My question is how can I export the data that I have in my QTableView to an excel file, that is, how can I create a file from the Table, is it possible to do that in Qt, I would appreciate any suggestions, greetings

    Solitary wolf

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Iterate over the model and write the data out into a csv file.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • artwawA Offline
        artwawA Offline
        artwaw
        wrote on last edited by artwaw
        #3

        Hi,
        first result from Google asked "qt xls" https://wiki.qt.io/Handling_Microsoft_Excel_file_format

        You can, of course, implement something yourself, xls format is dumb, it is actually zipped folder tree: https://docs.fileformat.com/spreadsheet/xlsx/

        EDIT: of course, @Christian-Ehrlicher is also right, you can use intermediate file like csv for the import purpose.

        For more information please re-read.

        Kind Regards,
        Artur

        1 Reply Last reply
        1
        • lincolnL lincoln

          hello friends, i have a query about a QTableView.
          My question is how can I export the data that I have in my QTableView to an excel file, that is, how can I create a file from the Table, is it possible to do that in Qt, I would appreciate any suggestions, greetings

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

          @lincoln
          I had to do this in my first Qt code. Write an export to Excel/PDF of any QTableView. I didn't find, or choose to use, anything ready-made. It's a lot easier to do it via a .csv file as @Christian-Ehrlicher says. Do it from the model.

          I also allowed to produce Excel file for control over layout etc., but I was in Python so able to use an export-to-XLSX library which may not be available to you if you are C++. (BTW, via CSV file you can have data values for cells and that's it; you cannot make it look like the QTableView with widths or colours or lines or anything. If that is important for your usage you can't go via CSV, just so you know.)

          1 Reply Last reply
          0
          • lincolnL Offline
            lincolnL Offline
            lincoln
            wrote on last edited by
            #5

            ok thanks, I'll try to do what you suggest, the important thing is to migrate that data to an excel because they ask for it at work.

            Solitary wolf

            Thank YouT 1 Reply Last reply
            0
            • lincolnL lincoln

              ok thanks, I'll try to do what you suggest, the important thing is to migrate that data to an excel because they ask for it at work.

              Thank YouT Offline
              Thank YouT Offline
              Thank You
              wrote on last edited by
              #6

              @lincoln Did you get the way to do it ?
              Can you share your code if you have done it

              Let's make QT free or It will go forever

              TRUE AND FALSE <3

              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