|
| 1 | +# UnoGenerator Helpers Specification |
| 2 | + |
| 3 | +Detailed reference of all helper functions in `unogenerator.helpers`. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | +1. [Totals Generation (Basic)](#1-totals-generation-basic) |
| 7 | +2. [Totals Generation (Titled)](#2-totals-generation-titled) |
| 8 | +3. [Advanced Totals (Cross-Calculations)](#3-advanced-totals-cross-calculations) |
| 9 | +4. [Data Block Helpers](#4-data-block-helpers) |
| 10 | +5. [Complete Sheet Helpers](#5-complete-sheet-helpers) |
| 11 | +6. [Utility Helpers](#6-utility-helpers) |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## 1. Totals Generation (Basic) |
| 16 | + |
| 17 | +### `row_totals` |
| 18 | +Generates a horizontal row of formulas. |
| 19 | +- `doc` (ODS): The ODS document object. |
| 20 | +- `coord` (Coord or str): Starting coordinate. |
| 21 | +- `list_of_totals` (list): List of formula keys (e.g. `["#SUM", "#AVG"]`). |
| 22 | +- `color` (int, default=ColorsNamed.GrayLight): Background color. |
| 23 | +- `styles` (list or str, default=None): Cell style(s). |
| 24 | +- `row_from` (str, default="2"): Start row for calculation range. |
| 25 | +- `row_to` (str, default=None): End row for calculation range. |
| 26 | + |
| 27 | +### `column_totals` |
| 28 | +Generates a vertical column of formulas. |
| 29 | +- `doc` (ODS): The ODS document object. |
| 30 | +- `coord` (Coord or str): Starting coordinate. |
| 31 | +- `list_of_totals` (list): List of formula keys. |
| 32 | +- `color` (int, default=ColorsNamed.GrayLight): Background color. |
| 33 | +- `styles` (list or str, default=None): Cell style(s). |
| 34 | +- `column_from` (str, default="B"): Start column for calculation range. |
| 35 | +- `column_to` (str, default=None): End column for calculation range. |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## 2. Totals Generation (Titled) |
| 40 | + |
| 41 | +### `row_title_values_total` |
| 42 | +Creates a row with a title, a sequence of values, and their sum. |
| 43 | +- `doc` (ODS): The ODS document object. |
| 44 | +- `coord` (Coord or str): Starting coordinate. |
| 45 | +- `title` (str): Title for the row. |
| 46 | +- `values` (list): List of numerical values. |
| 47 | +- `style_title` (str, default="Bold"): Style for the title. |
| 48 | +- `color_title` (int, default=ColorsNamed.Orange): Title color. |
| 49 | +- `style_values` (str, default=None): Style for the values. |
| 50 | +- `color_values` (int, default=ColorsNamed.White): Values color. |
| 51 | +- `style_total` (str, default=None): Style for the total. |
| 52 | +- `color_total` (int, default=ColorsNamed.GrayLight): Total color. |
| 53 | + |
| 54 | +### `column_title_values_total` |
| 55 | +Creates a column with a title, a sequence of values, and their sum. |
| 56 | +- `doc` (ODS): The ODS document object. |
| 57 | +- `coord` (Coord or str): Starting coordinate. |
| 58 | +- `title` (str): Title for the column. |
| 59 | +- `values` (list): List of numerical values. |
| 60 | +- `style_title` (str, default="Bold"): Style for the title. |
| 61 | +- `color_title` (int, default=ColorsNamed.Orange): Title color. |
| 62 | +- `style_values` (str, default=None): Style for the values. |
| 63 | +- `color_values` (int, default=ColorsNamed.White): Values color. |
| 64 | +- `style_total` (str, default=None): Style for the total. |
| 65 | +- `color_total` (int, default=ColorsNamed.GrayLight): Total color. |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## 3. Advanced Totals (Cross-Calculations) |
| 70 | + |
| 71 | +### `cross_totals_from_range` |
| 72 | +Generates optimized vertical and horizontal totals for a data range. |
| 73 | +- `doc` (ODS): The ODS document object. |
| 74 | +- `range_of_data` (Range or str): The data range to calculate from. |
| 75 | +- `key` (str, default="#SUM"): Formula alias, function name, or template (e.g. `"=SUM({}*1.21)"`). |
| 76 | +- `column_of_totals` (bool, default=True): If True, adds column at the right. |
| 77 | +- `row_of_totals` (bool, default=True): If True, adds row at the bottom. |
| 78 | +- `vertical_total_title_style` (str, default="BoldCenter"): Style for right label. |
| 79 | +- `horizontal_total_title_style` (str, default="BoldCenter"): Style for bottom label. |
| 80 | +- `showing` (bool, default=False): Legacy. If True, adds extra "Sum of totals" block. |
| 81 | +- `label_column` (str, default="Total"): Text for the vertical total label. |
| 82 | +- `label_row` (str, default="Total"): Text for the horizontal total label. |
| 83 | +- `skip_columns` (int, default=0): Number of columns to skip for bottom row totals. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## 4. Data Block Helpers |
| 88 | + |
| 89 | +### `block_from_lod` |
| 90 | +Inserts data from a List of Ordered Dictionaries. |
| 91 | +- `doc` (ODS): The ODS document object. |
| 92 | +- `coord_start` (Coord or str): Starting coordinate. |
| 93 | +- `lod_` (list): The list of dictionaries. |
| 94 | +- `keys` (list, default=None): Specific keys to write. |
| 95 | +- `columns_header` (int, default=0): Number of columns to color as headers. |
| 96 | +- `color_row_header` (int, default=ColorsNamed.Orange): Color for the keys row. |
| 97 | +- `color_column_header` (int, default=ColorsNamed.Green): Color for the header columns. |
| 98 | +- `color` (int, default=ColorsNamed.White): Background for data cells. |
| 99 | +- `styles` (list or str, default=None): Styles for data cells. |
| 100 | +- `column_of_totals` (bool, default=False): Generate totals on the right. |
| 101 | +- `row_of_totals` (bool, default=False): Generate totals at the bottom. |
| 102 | +- `key` (str, default="#SUM"): Formula key (see `cross_totals_from_range`). |
| 103 | +- `title` (str, default=None): Merged title for the block. |
| 104 | +- `word_wrap` (bool, default=True): Enable text wrapping. |
| 105 | + |
| 106 | +### `block_from_lol` |
| 107 | +Inserts data from a List of Lists. |
| 108 | +- `doc` (ODS): The ODS document object. |
| 109 | +- `coord_start` (Coord or str): Starting coordinate. |
| 110 | +- `lor` (list): The list of lists. |
| 111 | +- `headers` (list, default=None): Column header names. |
| 112 | +- `colors` (list or int, default=ColorsNamed.White): Column colors. |
| 113 | +- `styles` (list or str, default=None): Column styles. |
| 114 | +- `column_of_totals` (bool, default=False): Generate totals on the right. |
| 115 | +- `row_of_totals` (bool, default=False): Generate totals at the bottom. |
| 116 | +- `key` (str, default="#SUM"): Formula key. |
| 117 | +- `title` (str, default=None): Merged title for the block. |
| 118 | +- `word_wrap` (bool, default=True): Enable text wrapping. |
| 119 | + |
| 120 | +### `block_from_lod_with_headers` |
| 121 | +LOD writer with hierarchical sub-headers. |
| 122 | +- `doc` (ODS): The ODS document object. |
| 123 | +- `lod_` (list): List of dictionaries. |
| 124 | +- `coord` (Coord or str): Starting coordinate. |
| 125 | +- `subtitles` (list, default=[]): Groups of columns. List of `[title, first_key]`. |
| 126 | +- `titulo` (str, default=None): Main title. |
| 127 | +- `column_of_totals` (bool, default=False): Generate totals on the right. |
| 128 | +- `row_of_totals` (bool, default=False): Generate totals at the bottom. |
| 129 | +- `freezeandselect` (Coord or str, default=None): Auto-freeze coordinate. |
| 130 | +- `key` (str, default="#SUM"): Formula key. |
| 131 | +- `word_wrap` (bool, default=True): Enable text wrapping. |
| 132 | + |
| 133 | +--- |
| 134 | + |
| 135 | +## 5. Complete Sheet Helpers |
| 136 | + |
| 137 | +### `sheet_from_lod` |
| 138 | +Creates a new sheet and populates it from an LOD. |
| 139 | +- `doc` (ODS): The ODS document object. |
| 140 | +- `sheetname` (str): Name of the new sheet. |
| 141 | +- `lod_` (list): List of dictionaries. |
| 142 | +- `column_of_totals` (bool, default=False): Right totals. |
| 143 | +- `row_of_totals` (bool, default=False): Bottom totals. |
| 144 | +- `freezeandselect` (str, default=None): Coordination to freeze. |
| 145 | +- `title` (str, default=None): Main title. |
| 146 | +- `word_wrap` (bool, default=True): Text wrap. |
| 147 | +- `styles` (list or str, default=None): Data styles. |
| 148 | +- `**kwargs_columnswidth`: Extra params for column width calculation. |
| 149 | + |
| 150 | +### `sheet_from_lol` |
| 151 | +Creates a new sheet and populates it from an LOL. |
| 152 | +- `doc` (ODS): The ODS document object. |
| 153 | +- `sheetname` (str): Name of the new sheet. |
| 154 | +- `lor` (list): List of lists. |
| 155 | +- `headers` (list): Header names. |
| 156 | +- `column_of_totals` (bool, default=False): Right totals. |
| 157 | +- `row_of_totals` (bool, default=False): Bottom totals. |
| 158 | +- `freezeandselect` (str, default=None): Coordination to freeze. |
| 159 | +- `titulo` (str, default=None): Main title. |
| 160 | +- `word_wrap` (bool, default=True): Text wrap. |
| 161 | +- `**kwargs_columnswidth`: Extra params for column width calculation. |
| 162 | + |
| 163 | +### `sheet_split_with_big_lol` |
| 164 | +Creates multiple sheets for massive datasets. |
| 165 | +- `doc` (ODS): The ODS document object. |
| 166 | +- `sheet_name` (str): Base name for sheets. |
| 167 | +- `lor` (list): Massive list of lists. |
| 168 | +- `headers` (list): Header names. |
| 169 | +- `headers_colors` (int, default=ColorsNamed.Orange): Header background. |
| 170 | +- `coord_to_freeze` (Coord or str, default="A2"): Freeze coordinate. |
| 171 | +- `max_rows` (int, default=1048575): Max rows per sheet. |
| 172 | +- `word_wrap` (bool, default=True): Text wrap. |
| 173 | + |
| 174 | +--- |
| 175 | + |
| 176 | +## 6. Utility Helpers |
| 177 | + |
| 178 | +### `sheet_stylenames` |
| 179 | +Generates a reference sheet with available document styles. |
| 180 | +- `doc` (ODS): The ODS document object. |
0 commit comments