diff --git a/app/services/reports/docx/draw_result_table.rb b/app/services/reports/docx/draw_result_table.rb index c63d29d9e..5af30343f 100644 --- a/app/services/reports/docx/draw_result_table.rb +++ b/app/services/reports/docx/draw_result_table.rb @@ -8,6 +8,20 @@ module Reports::Docx::DrawResultTable obj = self table_data = JSON.parse(table.contents_utf_8)['data'] table_data = obj.add_headers_to_table(table_data, false) + + if table.metadata.present? + table.metadata['cells']&.each do |cell| + next unless cell['row'].present? && cell['col'].present? + + row_index = cell['row'].to_i + 1 + col_index = cell['col'].to_i + 1 + calculated_value = cell['calculated'] + + if calculated_value.present? + table_data[row_index][col_index] = calculated_value + end + end + end @docx.p @docx.table table_data, border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE do cell_style rows[0], bold: true, background: color[:concrete] diff --git a/app/services/reports/docx/draw_step_table.rb b/app/services/reports/docx/draw_step_table.rb index 758ffdd2a..96f1be45e 100644 --- a/app/services/reports/docx/draw_step_table.rb +++ b/app/services/reports/docx/draw_step_table.rb @@ -7,6 +7,20 @@ module Reports::Docx::DrawStepTable obj = self table_data = JSON.parse(table.contents_utf_8)['data'] table_data = obj.add_headers_to_table(table_data, table_type == 'step_well_plates_table') + + if table.metadata.present? + table.metadata['cells']&.each do |cell| + next unless cell['row'].present? && cell['col'].present? + + row_index = cell['row'].to_i + 1 + col_index = cell['col'].to_i + 1 + calculated_value = cell['calculated'] + + if calculated_value.present? + table_data[row_index][col_index] = calculated_value + end + end + end @docx.p @docx.table table_data, border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE do cell_style rows[0], bold: true, background: color[:concrete]