diff options
| author | rikweelvoormedia <[email protected]> | 2023-08-15 09:30:15 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-15 09:30:15 +0200 |
| commit | c71a735991b3ab1bf8f5ead894476898e70c7700 (patch) | |
| tree | 8014880fb5f1ec3835bf847b0af781c7b10336d5 /examples/sort_state_example.md | |
| parent | 8a8a256602283debc7b116ab11a2cf64ba56222c (diff) | |
| download | caxlsx-c71a735991b3ab1bf8f5ead894476898e70c7700.tar.gz caxlsx-c71a735991b3ab1bf8f5ead894476898e70c7700.zip | |
Added sorting to the AutoFilter class - add sort conditions to the xml (#286)
---------
Co-authored-by: SarahVanHaute <[email protected]>
Co-authored-by: Geremia Taglialatela <[email protected]>
Diffstat (limited to 'examples/sort_state_example.md')
| -rw-r--r-- | examples/sort_state_example.md | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/sort_state_example.md b/examples/sort_state_example.md new file mode 100644 index 00000000..d0258c31 --- /dev/null +++ b/examples/sort_state_example.md @@ -0,0 +1,42 @@ +## Description + +You could add sort conditions to the sort state of an auto filtered table + +## Code + +```ruby +require 'axlsx' + +p = Axlsx::Package.new +wb = p.workbook + +wb.add_worksheet(name: 'Sort State') do |sheet| + sheet.add_row ['Number', 'Letter', 'Priority'] + sheet.add_row [1, 'B', 'high'] + sheet.add_row [2, 'B', 'low'] + sheet.add_row [3, 'B', 'medium'] + sheet.add_row [4, 'B', 'high'] + sheet.add_row [5, 'B', 'low'] + sheet.add_row [6, 'B', 'medium'] + sheet.add_row [7, 'A', 'high'] + sheet.add_row [8, 'A', 'low'] + sheet.add_row [9, 'A', 'medium'] + sheet.add_row [10, 'A', 'high'] + sheet.add_row [11, 'A', 'low'] + sheet.add_row [12, 'A', 'medium'] + sheet.auto_filter = 'A1:C13' + sheet.auto_filter.sort_state.add_sort_condition column_index: 1 + sheet.auto_filter.sort_state.add_sort_condition column_index: 2, custom_list: ['low', 'medium', 'high'] + sheet.auto_filter.sort_state.add_sort_condition column_index: 0, order: :desc +end + +p.serialize 'sort_state_example.xlsx' +``` + +## Output + + + +After adding the sort conditions: + + |
