summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-05-24 02:55:49 -0700
committerRandy Morgan <[email protected]>2012-05-24 02:55:49 -0700
commitaaac7558a4a5ca3b7a62d85202545662d17a296b (patch)
tree92f0f82ae90e63a1ff920e2912b813a8a2ad39c0 /examples
parentb33dae1dab71485f8b292e9212dd4ab0c62b6812 (diff)
parent7ae571e152717841fdabe8eae7d1cba65ebfde4d (diff)
downloadcaxlsx-aaac7558a4a5ca3b7a62d85202545662d17a296b.tar.gz
caxlsx-aaac7558a4a5ca3b7a62d85202545662d17a296b.zip
Merge pull request #98 from janhuehne/data_validation
Data validation
Diffstat (limited to 'examples')
-rw-r--r--examples/data_validation.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/examples/data_validation.rb b/examples/data_validation.rb
new file mode 100644
index 00000000..56248ec3
--- /dev/null
+++ b/examples/data_validation.rb
@@ -0,0 +1,50 @@
+#!/usr/bin/env ruby -w -s
+# -*- coding: utf-8 -*-
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
+require 'axlsx'
+
+p = Axlsx::Package.new
+p.workbook.add_worksheet do |ws|
+ ws.add_data_validation("A10", {
+ :type => :whole,
+ :operator => :between,
+ :formula1 => '5',
+ :formula2 => '10',
+ :showErrorMessage => true,
+ :errorTitle => 'Wrong input',
+ :error => 'Only values between 5 and 10',
+ :errorStyle => :information,
+ :showInputMessage => true,
+ :promptTitle => 'Be carful!',
+ :prompt => 'Only values between 5 and 10'})
+
+ ws.add_data_validation("B10", {
+ :type => :textLength,
+ :operator => :greaterThan,
+ :formula1 => '10',
+ :showErrorMessage => true,
+ :errorTitle => 'Text is too long',
+ :error => 'Max text length is 10 characters',
+ :errorStyle => :stop,
+ :showInputMessage => true,
+ :promptTitle => 'Text length',
+ :prompt => 'Max text length is 10 characters'})
+
+ 8.times do |i|
+ ws.add_row [nil, nil, i*2]
+ end
+
+ ws.add_data_validation("C10", {
+ :type => :list,
+ :formula1 => 'C1:C8',
+ :showDropDown => false,
+ :showErrorMessage => true,
+ :errorTitle => '',
+ :error => 'Only values from C1:C8',
+ :errorStyle => :stop,
+ :showInputMessage => true,
+ :promptTitle => '',
+ :prompt => 'Only values from C1:C8'})
+end
+
+p.serialize 'data_validation.xlsx' \ No newline at end of file