def append_data_column(variable_name: str, data_column: List[Any], end_range: xw.Range = None, **table: TableInfo)->xw.Range: '''Adds the given data_column to the end of the designated excel table. Args: variable_name: The name for the new column. data_column: A list containing the data to be placed into the new column. end_range: Optional range of last column in current table. table: The table reference info supplied to get_table_range. Must contain: data_sheet: The excel worksheet containing the table. Optionally contains: starting_cell: the top right cell in the excel table. columns: The number of columns in the table. If 'expand', the table will include all columns left of starting_cell until the first empty cell is encountered. rows: The number of rows in the table. If 'expand', the table will include all rows below the starting_cell until the first empty cell is encountered. header: The number of variable header rows. Default is 1. To include the top row in the range selection set header to 0. Returns: An XLWings Range object for the new column. ''' if end_range is None: variables = get_variable_list(**table) end_variable = variables[-1] end_range = get_column_range(end_variable, **table) new_range = end_range.offset(column_offset=1) header_range = new_range[0].offset(row_offset=-1) header_range.value = variable_name new_range.options(transpose=True).value = data_column return new_range
def get_column_header_color(header_cell: xw.Range) -> int: header_str: str = str(header_cell.value).lower() value_cell = header_cell.offset(1, 0) if header_str.startswith('used_'): return Color.USED_IDENTIFIER elif header_is_index(header_str): return Color.INDEX elif value_cell.value is None: return Color.INPUT elif str(value_cell.formula)[0] != '=': return Color.INPUT else: return Color.CALCULATION