def set_formula( name: str, fn: Callable = None, args: str = None, xl: w32 = None, replace: bool = False, ): """ Set a formula ina given cell. Used to instantiate objects like data_obj_cfg and data_obj_manager Parameters ---------- name: str Excel named range fn: Callable A function to be executed args: str Arguments to the function xl: {None, xl_app} replace: bool Replace if exists flag """ args = "" if not args else args if isinstance(fn, FunctionType): formula = f"={fn.__name__}({args})" else: formula = "" if not check_object_alive(name) or replace: # logging.info(f"Setting {name} as {formula}") xl.Range(name).Formula = formula
def excel_styler(address: str, style_format: str, xl: w32 = None): """ Styles a Excel Range Parameters ---------- address: str Excel Address style_format: str Excel Styling option xl: {None, xl_app} """ xl.Range(address).Style = style_format
def set_value(name, value, xl: w32 = None): """ Sets value in a given range Parameters ---------- name: str Excel named range value: value Value to be placed in the range xl: {None, xl_app} """ # logging.info(f"Setting {name} value") xl.Range(name).Value = value
def excel_formatter(address: str, format_option: str, xl: w32 = None): """ Formats a Excel Range Parameters ---------- address: str Excel Address format_option: str Excel Formatting option. For further information, https://support.microsoft.com/en-us/help/264372/how-to-control-and-understand-settings-in-the-format-cells-dialog-box xl: {None, xl_app} """ xl.Range(address).NumberFormat = format_option
def excel_data_bar(address: str, xl: w32 = None): xl.Range(address).BarFillType = win32.constants.xlDataBarFillSolid