Commit 0c4f8863 authored by suryakant's avatar suryakant

ACP Custom Report Changes

parent 975dc483
......@@ -196,6 +196,7 @@ class CustomReportHandler:
column_counter = 0
previous_category_cols = 0
header_flag = False
color_json = dict()
logger.info("Iterating through each block to create a dataframe")
# Iterate through the categories and concatenate their data
......@@ -221,6 +222,13 @@ class CustomReportHandler:
column_counter += shape[1]
previous_category_cols = column_counter
# Checking if color in addition section
if "addition" in category_data and "column_color" in category_data[
"addition"]:
color_json.update(
category_data["addition"]["column_color"]
)
if header_flag:
start_row += 1
......@@ -238,17 +246,28 @@ class CustomReportHandler:
# Generating merged header for each dataframe
for merge_index, border_value in border_json.items():
# (Start Rows, Start Column, End Row, End Column, Title, Format)
if border_value and border_value in color_json:
merge_style_format = copy.deepcopy(header_merge_format)
merge_style_format["fg_color"] = color_json[border_value]
worksheet.merge_range(*merge_index, border_value,
workbook.add_format(merge_style_format))
else:
worksheet.merge_range(*merge_index, border_value,
workbook.add_format(header_merge_format))
# Write the column headers with the defined format.
for col_index, value in enumerate(result_df.columns.values):
if value:
if color_json and value in color_json:
style_format = copy.deepcopy(column_merge_format)
style_format["fg_color"] = color_json[value]
worksheet.write(
start_row, col_index, value,
workbook.add_format(column_merge_format)
)
workbook.add_format(style_format))
else:
worksheet.write(
start_row, col_index, value,
workbook.add_format(column_merge_format))
else:
worksheet.write(
start_row, col_index, value,
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment