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 transform Excel, CSV ,Sqlite
QtWS25 Last Chance

How To transform Excel, CSV ,Sqlite

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 5 Posters 3.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.
  • pyuxingP Offline
    pyuxingP Offline
    pyuxing
    wrote on last edited by
    #1

    What I want to do is that modify the data by Excel and use data in QT by sqlite.
    I didn't find the way transform excel to sqlite(or save excel as sqlite).
    and now I have transformed Excel to CSV,but I didn't find the way to transform CSV to sqlite.
    Has anyone have some tips about this QT program. Any tips will help.
    Thanks a lot .

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      For an analogy:

      • Excel = car
      • CSV = bike
      • sqlite = truck

      They all have wheels but they are not straight convertable from one to the other. What exactly are you trying to do? putting an excel table as a new table in the sqlite db?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      pyuxingP 1 Reply Last reply
      6
      • Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @pyuxing said in How To transform Excel, CSV ,Sqlite:

        Has anyone have some tips about this QT program

        Although I'm a big fan of people using Qt everywhere, there would be some use cases where it won't be the ideal tool. Are you sure you cannot do the Excel -> sqlite conversion/data handling in other (more direct) way not using a Qt application? What about using SQLite ODBC driver?

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        1
        • mrdebugM Offline
          mrdebugM Offline
          mrdebug
          wrote on last edited by
          #4

          Yes you can.
          Please remember that csv can manage only one sheet (one table). If you want you can write some lines of code to read a csv file and to create a sqlite table with the data.
          To manage a xls file you can use QSqlDatabase::addDatabase("QODBC");
          or ADO interface.

          Need programmers to hire?
          www.labcsp.com
          www.denisgottardello.it
          GMT+1
          Skype: mrdebug

          1 Reply Last reply
          4
          • VRoninV VRonin

            For an analogy:

            • Excel = car
            • CSV = bike
            • sqlite = truck

            They all have wheels but they are not straight convertable from one to the other. What exactly are you trying to do? putting an excel table as a new table in the sqlite db?

            pyuxingP Offline
            pyuxingP Offline
            pyuxing
            wrote on last edited by
            #5

            @VRonin
            Thanks for your reply.
            Yeah,I just want import the excel table into sqlite db,so any tips for this?

            1 Reply Last reply
            0
            • mrdebugM Offline
              mrdebugM Offline
              mrdebug
              wrote on last edited by
              #6

              You have to write code.
              If you need professional support please send me an email.
              You can find my email in the signature company website.

              Need programmers to hire?
              www.labcsp.com
              www.denisgottardello.it
              GMT+1
              Skype: mrdebug

              pyuxingP 1 Reply Last reply
              0
              • mrdebugM mrdebug

                You have to write code.
                If you need professional support please send me an email.
                You can find my email in the signature company website.

                pyuxingP Offline
                pyuxingP Offline
                pyuxing
                wrote on last edited by
                #7

                @mrdebug
                So I have to try to use "ODBC"?

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  Hi
                  If you need to export multiple sheets in one go, CSV is not a good export format as it has
                  no sheet concept. So minimum is you would have to export the sheets to individual files
                  and import each one to the database system.

                  Pablo J. RoginaP 1 Reply Last reply
                  2
                  • mrjjM mrjj

                    Hi
                    If you need to export multiple sheets in one go, CSV is not a good export format as it has
                    no sheet concept. So minimum is you would have to export the sheets to individual files
                    and import each one to the database system.

                    Pablo J. RoginaP Offline
                    Pablo J. RoginaP Offline
                    Pablo J. Rogina
                    wrote on last edited by Pablo J. Rogina
                    #9

                    @pyuxing if you have the CSV file at hand you can import it directly to an sqlite table using sqlite3 tool, see this tutorial. As stated before, if your Excel file has several sheets you need to repeat the process per worksheet (you'll end up with several tables in sqlite db).

                    Other option is to connect the Excel worksheet directly to the sqlite db via an ODBC driver.

                    Last option, and more complex and laborious is to create an Qt application that read the CSV file, and assuming it has first line as header names, creates an sqlite table and then reading line by line inserts the data as rows in the sqlite table

                    And as summary of my post, this issue you have seems to be not related to Qt framework at all.

                    Upvote the answer(s) that helped you solve the issue
                    Use "Topic Tools" button to mark your post as Solved
                    Add screenshots via postimage.org
                    Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                    pyuxingP 1 Reply Last reply
                    4
                    • Pablo J. RoginaP Pablo J. Rogina

                      @pyuxing if you have the CSV file at hand you can import it directly to an sqlite table using sqlite3 tool, see this tutorial. As stated before, if your Excel file has several sheets you need to repeat the process per worksheet (you'll end up with several tables in sqlite db).

                      Other option is to connect the Excel worksheet directly to the sqlite db via an ODBC driver.

                      Last option, and more complex and laborious is to create an Qt application that read the CSV file, and assuming it has first line as header names, creates an sqlite table and then reading line by line inserts the data as rows in the sqlite table

                      And as summary of my post, this issue you have seems to be not related to Qt framework at all.

                      pyuxingP Offline
                      pyuxingP Offline
                      pyuxing
                      wrote on last edited by
                      #10

                      @Pablo-J.-Rogina
                      connecting the Excel worksheet directly to the sqlite db via an ODBC driver maybe the best choice ,I`ll have a try.Thanks!

                      VRoninV 1 Reply Last reply
                      1
                      • pyuxingP pyuxing

                        @Pablo-J.-Rogina
                        connecting the Excel worksheet directly to the sqlite db via an ODBC driver maybe the best choice ,I`ll have a try.Thanks!

                        VRoninV Offline
                        VRoninV Offline
                        VRonin
                        wrote on last edited by
                        #11

                        @pyuxing You'll probably find this wiki interesting: https://wiki.qt.io/Handling_Microsoft_Excel_file_format

                        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                        ~Napoleon Bonaparte

                        On a crusade to banish setIndexWidget() from the holy land of Qt

                        1 Reply Last reply
                        4

                        • Login

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