Writing to a CSV file - can we add colour to a cell?
-
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
-
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
@aftershocker1
A CSV file is just for exporting the data. No other information (other than an optional column header row). -
@aftershocker1
A CSV file is just for exporting the data. No other information (other than an optional column header row).@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
-
@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
Hi
Well excel can import a HTML table so it is possible.
Just not with the CSV format. -
@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
-
@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
@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.
-
Hi
Well excel can import a HTML table so it is possible.
Just not with the CSV format.@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.
-
@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.
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 :) -
@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.
@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 WindowsQAxObject
. It's a lot more work than a plain CSV file! -
@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 WindowsQAxObject
. It's a lot more work than a plain CSV file!@JonB Thanks. It is not going to be worth the hassle this time but all good info for the future.