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. Writing to a CSV file - can we add colour to a cell?
QtWS25 Last Chance

Writing to a CSV file - can we add colour to a cell?

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 5 Posters 791 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.
  • A Offline
    A Offline
    aftershocker1
    wrote on last edited by
    #1

    Hello,

    I am outputting data to a CSV file. The data is writing correctly and saving where I want it to save to. I was wondering if there was any way to add colour to a cell? For example if a bool is true the the cell would be green, false it would be red? I think as it is just a text stream that I will be unable to do this but thought it would be worth asking the forum. Thought process is that as opposed to having extra cells with pass/fail result if the numerical data is colour code depending on the result it will save the CSV being 100 cells long and be more readable for the user.

    Thanks

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

      You want a plain text file to appear in colour when opened in what?

      A 1 Reply Last reply
      2
      • A aftershocker1

        Hello,

        I am outputting data to a CSV file. The data is writing correctly and saving where I want it to save to. I was wondering if there was any way to add colour to a cell? For example if a bool is true the the cell would be green, false it would be red? I think as it is just a text stream that I will be unable to do this but thought it would be worth asking the forum. Thought process is that as opposed to having extra cells with pass/fail result if the numerical data is colour code depending on the result it will save the CSV being 100 cells long and be more readable for the user.

        Thanks

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

        @aftershocker1
        A CSV file is just for exporting the data. No other information (other than an optional column header row).

        A 1 Reply Last reply
        1
        • JonBJ JonB

          @aftershocker1
          A CSV file is just for exporting the data. No other information (other than an optional column header row).

          A Offline
          A Offline
          aftershocker1
          wrote on last edited by
          #4

          @JonB Thanks. That's what I thought I just wondered if Qt had something built it that allowed it to be displayed in a different format in a spreadsheet.

          Thanks for your help

          mrjjM 1 Reply Last reply
          0
          • A aftershocker1

            @JonB Thanks. That's what I thought I just wondered if Qt had something built it that allowed it to be displayed in a different format in a spreadsheet.

            Thanks for your help

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

            @aftershocker1

            Hi
            Well excel can import a HTML table so it is possible.
            Just not with the CSV format.

            A 1 Reply Last reply
            0
            • C ChrisW67

              You want a plain text file to appear in colour when opened in what?

              A Offline
              A Offline
              aftershocker1
              wrote on last edited by
              #6

              @ChrisW67 I just wondered if when opened in a spreadsheet if there could be some basic formatting of the cells. I am aware that that isn't possible

              JKSHJ 1 Reply Last reply
              0
              • A aftershocker1

                @ChrisW67 I just wondered if when opened in a spreadsheet if there could be some basic formatting of the cells. I am aware that that isn't possible

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #7

                @aftershocker1 said in Writing to a CSV file - can we add colour to a cell?:

                I just wondered if when opened in a spreadsheet if there could be some basic formatting of the cells.

                Opened with what?

                If you are writing your own CSV viewer, you can set the view's cell's colour. Note that the formatting occurs in the viewer, not in the CSV file itself.

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • mrjjM mrjj

                  @aftershocker1

                  Hi
                  Well excel can import a HTML table so it is possible.
                  Just not with the CSV format.

                  A Offline
                  A Offline
                  aftershocker1
                  wrote on last edited by
                  #8

                  @mrjj Sound like it could be interesting in the future. For this is just basic data for engineers to analyse so doesn't need to look overly fancy. In my head I thought it would have been good to have a cell green if true/pass but I will just put the reading in a cell then the next cell showing the result as a bool.

                  mrjjM JonBJ 2 Replies Last reply
                  0
                  • A aftershocker1

                    @mrjj Sound like it could be interesting in the future. For this is just basic data for engineers to analyse so doesn't need to look overly fancy. In my head I thought it would have been good to have a cell green if true/pass but I will just put the reading in a cell then the next cell showing the result as a bool.

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

                    @aftershocker1

                    Well if only to mark rows for ok/fail then i think using a column will also work fine.
                    Besides, the engineers can most likely apply conditional formatting in Excel and
                    color it based on value if they want :)

                    1 Reply Last reply
                    1
                    • A aftershocker1

                      @mrjj Sound like it could be interesting in the future. For this is just basic data for engineers to analyse so doesn't need to look overly fancy. In my head I thought it would have been good to have a cell green if true/pass but I will just put the reading in a cell then the next cell showing the result as a bool.

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

                      @aftershocker1
                      To be clear: if you want formatting (like color etc.) you can't just export as CSV, you have to export as an actual Excel file. Either an XLSX writer library, or if you are on Windows QAxObject. It's a lot more work than a plain CSV file!

                      A 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @aftershocker1
                        To be clear: if you want formatting (like color etc.) you can't just export as CSV, you have to export as an actual Excel file. Either an XLSX writer library, or if you are on Windows QAxObject. It's a lot more work than a plain CSV file!

                        A Offline
                        A Offline
                        aftershocker1
                        wrote on last edited by
                        #11

                        @JonB Thanks. It is not going to be worth the hassle this time but all good info for the future.

                        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