Export Perspective Power table data and format to Excel

Using this documentation to make my table rows different colors based on the value of one of the columns.


# This list will be used to create a JSON like structure that will insert rows for our styles

output_json = []

# Here we can define what styling on our rows will be.

style_orange = { "backgroundColor" : "#F7901D" }

style_green = { "backgroundColor" : "#00AA00" }

# You could change more than just the background color, for example:

# style_another_example {"backgroundColor": "#00AA00", "font-weight": "bold"}

for row in range (value.getRowCount()):

row_object = {}

row_value = {}

row_style = {}

for col in range (value.getColumnCount()):

row_value[value.getColumnName(col)] = value.getValueAt(row, col)

row_object[ 'value' ] = row_value

# Here we're checking the name of the column that we want to base our styling on.

if value.getColumnName(col) = = 'B' :

# Here we're checking for individual values within the column, and applying styling

if value.getValueAt(row, col) = = 'One' :

row_style = style_orange

elif value.getValueAt(row, col) = = 'Two' :

row_style = style_green

row_object[ 'style' ] = row_style


return output_json

Is there a way to export the data to excel and maintain the color formatting?

Hi, beckya. Please have a read of Wiki - how to post code on this forum and then hit the pencil icon below your post to format the code.