diff options
| author | Stefan Daschek <[email protected]> | 2022-07-09 13:20:00 +0200 |
|---|---|---|
| committer | Stefan Daschek <[email protected]> | 2022-07-09 13:20:21 +0200 |
| commit | 3e327e3094c8096d81062bdb71f563cf7bbc8178 (patch) | |
| tree | 787b8e27b839d3778a8a71c24d7c3de45b05e915 /examples | |
| parent | 5ae8ef157be8d57db45cd90313e3e54c3f91f063 (diff) | |
| download | caxlsx-3e327e3094c8096d81062bdb71f563cf7bbc8178.tar.gz caxlsx-3e327e3094c8096d81062bdb71f563cf7bbc8178.zip | |
Improve list validation example
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/images/list_validation_example_1.png | bin | 23711 -> 103286 bytes | |||
| -rw-r--r-- | examples/images/list_validation_example_2.png | bin | 24695 -> 82267 bytes | |||
| -rw-r--r-- | examples/list_validation_example.md | 39 |
3 files changed, 25 insertions, 14 deletions
diff --git a/examples/images/list_validation_example_1.png b/examples/images/list_validation_example_1.png Binary files differindex 3f0b9077..a730dd7a 100644 --- a/examples/images/list_validation_example_1.png +++ b/examples/images/list_validation_example_1.png diff --git a/examples/images/list_validation_example_2.png b/examples/images/list_validation_example_2.png Binary files differindex 8feaaba6..cd550a57 100644 --- a/examples/images/list_validation_example_2.png +++ b/examples/images/list_validation_example_2.png diff --git a/examples/list_validation_example.md b/examples/list_validation_example.md index 1f2cfc0c..7c44fc2c 100644 --- a/examples/list_validation_example.md +++ b/examples/list_validation_example.md @@ -11,31 +11,42 @@ p = Axlsx::Package.new wb = p.workbook wb.add_worksheet(name: 'Basic Worksheet') do |sheet| - sheet.add_row ['First', 'Second', 'Third'] - sheet.add_row [1, 6, 11] - - sheet.add_data_validation('A2:A2', + sheet.add_row ['Fixed list', 'small'] + sheet.add_row ['Dynamic list', 'red'] + sheet.add_row ['No dropdown', 'north'] + sheet.add_row + sheet.add_row ['Allowed values in B2 (dynamic list):', 'red', 'orange', 'navy blue'] + sheet.add_data_validation('B1:B1', type: :list, - formula1: 'A1:C1', - showDropDown: false, + formula1: '"small, medium, large"', showErrorMessage: true, errorTitle: '', - error: 'Only values from A1:C1', + error: 'Allowed values: small, medium, large', errorStyle: :stop, showInputMessage: true, promptTitle: '', - prompt: 'Only values from A1:C1') + prompt: 'Choose a size:') sheet.add_data_validation('B2:B2', type: :list, - formula1: '"Red, Orange, NavyBlue"', - showDropDown: false, + formula1: 'B5:D5', + showErrorMessage: true, + errorTitle: '', + error: 'Only values from B5:D5 allowed!', + errorStyle: :stop, + showInputMessage: true, + prompt: 'Choose a color (from list in B5:D5):') + + sheet.add_data_validation('B3:B3', + type: :list, + formula1: '"north, east, south, west"', + showDropDown: true, # Note that this does in fact *hide* the dropdown. showErrorMessage: true, errorTitle: '', - error: 'Please use the dropdown selector to choose the value', + error: 'Allowed values: north, east, south, west', errorStyle: :stop, showInputMessage: true, - prompt: 'Choose the value from the dropdown') + prompt: 'Enter a direction:') end p.serialize 'list_validation_example.xlsx' @@ -43,10 +54,10 @@ p.serialize 'list_validation_example.xlsx' ## Output -Validating by cells: +Validating with dropdown:  -Validating by list: +Validating without dropdown:  |
