diff options
| author | Toms Mikoss <[email protected]> | 2022-04-14 21:06:31 +0300 |
|---|---|---|
| committer | Toms Mikoss <[email protected]> | 2022-04-14 21:06:31 +0300 |
| commit | 1679d6aa36b61339d8d2667e02323afa8a76002d (patch) | |
| tree | 3da5fb8db7bb41c1cad0d3a04c574fa3c14be2c3 | |
| parent | ed6e1ebddff733f8bb56399aa4dc9774096ba1c1 (diff) | |
| download | caxlsx-1679d6aa36b61339d8d2667e02323afa8a76002d.tar.gz caxlsx-1679d6aa36b61339d8d2667e02323afa8a76002d.zip | |
Add row outline options example
| -rw-r--r-- | examples/README.md | 1 | ||||
| -rw-r--r-- | examples/images/row_outlines_options_example_1.png | bin | 0 -> 17331 bytes | |||
| -rw-r--r-- | examples/row_outlines_options_example.md | 47 |
3 files changed, 48 insertions, 0 deletions
diff --git a/examples/README.md b/examples/README.md index c1335892..0e2d655a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -90,6 +90,7 @@ Customizations: * [Custom Row Styles](row_styles_example.md) * [Outlines](row_outlines_example.md) +* [Outline options](row_outlines_options_example.md) * [Row heights](row_heights_example.md) ### Sheet diff --git a/examples/images/row_outlines_options_example_1.png b/examples/images/row_outlines_options_example_1.png Binary files differnew file mode 100644 index 00000000..ae951849 --- /dev/null +++ b/examples/images/row_outlines_options_example_1.png diff --git a/examples/row_outlines_options_example.md b/examples/row_outlines_options_example.md new file mode 100644 index 00000000..27406aa2 --- /dev/null +++ b/examples/row_outlines_options_example.md @@ -0,0 +1,47 @@ +## Description + +Outline summary rows can be positioned below (default) or above the details, corresponding to "Summary rows below detail" option in Excel. + +Outline level can be set with helper methods (preferred), or on per-row basis. + +## Code + +```ruby +require 'axlsx' + +p = Axlsx::Package.new +wb = p.workbook + +s = wb.styles +summary = s.add_style b: true + +wb.add_worksheet(name: 'Row outlines options') do |sheet| + # This option specifies whether summary rows go above or below detail, worksheet-wide + sheet.sheet_pr.outline_pr.summary_below = false + + # When specifying outline levels without helper methods, you must enable outline symbols manually. + sheet.sheet_view.show_outline_symbols = true + + (1..4).map do |x| + sub_group_hidden = x % 2 == 0 + + x_row = sheet.add_row ["Group #{x}"], style: summary + # Outline depth level can be set as property on the row + x_row.outline_level = 0 + + (1..4).map do |y| + y_row = sheet.add_row [" Item #{x}-#{y}"] + y_row.outline_level = 1 + + # Whether or not the outline level starts collapsed is governed by the `hidden` property on the row + y_row.hidden = sub_group_hidden + end + end +end + +p.serialize 'row_outlines_options_example.xlsx' +``` + +## Output + + |
