diff options
| author | Jan-Hendrik Hühne <[email protected]> | 2012-05-24 11:13:36 +0200 |
|---|---|---|
| committer | Jan-Hendrik Hühne <[email protected]> | 2012-05-24 11:15:21 +0200 |
| commit | 3bdb2d71698f4630c275e72f80a838b905c8cd11 (patch) | |
| tree | 424371859b03fd5b3d9106baab1962c1a2c7964a /examples/data_validation.rb | |
| parent | b2122aac37250fd9a24fc4577560761327ecdced (diff) | |
| download | caxlsx-3bdb2d71698f4630c275e72f80a838b905c8cd11.tar.gz caxlsx-3bdb2d71698f4630c275e72f80a838b905c8cd11.zip | |
Examples
Diffstat (limited to 'examples/data_validation.rb')
| -rw-r--r-- | examples/data_validation.rb | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/examples/data_validation.rb b/examples/data_validation.rb index 84677066..56248ec3 100644 --- a/examples/data_validation.rb +++ b/examples/data_validation.rb @@ -5,8 +5,46 @@ require 'axlsx' p = Axlsx::Package.new p.workbook.add_worksheet do |ws| - data_validation_1 = { :type => :whole, :formula1 => '4', :formula2 => '10'} - - ws.add_data_validation("A1", data_validation_1) + 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_validations.xlsx' + +p.serialize 'data_validation.xlsx'
\ No newline at end of file |
