summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorStefan Daschek <[email protected]>2022-07-09 13:20:00 +0200
committerStefan Daschek <[email protected]>2022-07-09 13:20:21 +0200
commit3e327e3094c8096d81062bdb71f563cf7bbc8178 (patch)
tree787b8e27b839d3778a8a71c24d7c3de45b05e915 /examples
parent5ae8ef157be8d57db45cd90313e3e54c3f91f063 (diff)
downloadcaxlsx-3e327e3094c8096d81062bdb71f563cf7bbc8178.tar.gz
caxlsx-3e327e3094c8096d81062bdb71f563cf7bbc8178.zip
Improve list validation example
Diffstat (limited to 'examples')
-rw-r--r--examples/images/list_validation_example_1.pngbin23711 -> 103286 bytes
-rw-r--r--examples/images/list_validation_example_2.pngbin24695 -> 82267 bytes
-rw-r--r--examples/list_validation_example.md39
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
index 3f0b9077..a730dd7a 100644
--- a/examples/images/list_validation_example_1.png
+++ b/examples/images/list_validation_example_1.png
Binary files differ
diff --git a/examples/images/list_validation_example_2.png b/examples/images/list_validation_example_2.png
index 8feaaba6..cd550a57 100644
--- a/examples/images/list_validation_example_2.png
+++ b/examples/images/list_validation_example_2.png
Binary files differ
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:
![Output](images/list_validation_example_1.png "Output")
-Validating by list:
+Validating without dropdown:
![Output](images/list_validation_example_2.png "Output")