# Perspective table cell color

**URL:** <https://forum.inductiveautomation.com/t/perspective-table-cell-color/50047>\
**Category:** Ignition\
**Created:** [August 18, 2021, 1:58pm UTC](https://forum.inductiveautomation.com/t/perspective-table-cell-color/50047 "2021-08-18T13:58:13Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![eichler-eng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/eichler-eng/32/21259_2.png) [@eichler-eng](https://forum.inductiveautomation.com/u/eichler-eng)\
**Post date:** [August 18, 2021, 3:02pm UTC](https://forum.inductiveautomation.com/t/perspective-table-cell-color/50047/5 "2021-08-18T15:02:10Z")

</div>

Thanks for your help. That has cleaned up the code a little. I’ll work on sorting the key order in the json string later.

```auto
output_json = []
	    
	style_red = {"backgroundColor": "red"}
	style_green = {"backgroundColor": "green"}
	style_gray = {"backgroundColor": "gray"}
	
	for row in range(value.getRowCount()):
		row_object = {}
					
		for col in value.getColumnNames():    
			cell_object = {}
			cell_style = {}
			# Add a key/value pair for the cell
			cell_object['value']=value.getValueAt(row, col)
			
			# Select the style
			if col == 'LED':
				color = value.getValueAt(row, col)
				if color == 'red':
					cell_style = style_red
				elif color == 'green':
					cell_style = style_green
				elif color == 'gray':
					cell_style = style_gray
			
			cell_object['style']=cell_style
			
			#Add the cell object to the row object
			row_object[col]=cell_object
		
		#Add the row_object to the output					
		output_json.append(row_object)	
		
	return output_json

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/perspective-table-cell-color/50047)._
