examples/data_validate.rb in write_xlsx-1.10.0 vs examples/data_validate.rb in write_xlsx-1.10.1

- old
+ new

@@ -17,16 +17,16 @@ workbook = WriteXLSX.new('data_validate.xlsx') worksheet = workbook.add_worksheet # Add a format for the header cells. header_format = workbook.add_format( - :border => 1, - :bg_color => '#C6EFCE', - :bold => 1, - :text_wrap => 1, - :valign => 'vcenter', - :indent => 1 + border: 1, + bg_color: '#C6EFCE', + bold: 1, + text_wrap: 1, + valign: 'vcenter', + indent: 1 ) # Set up layout of the worksheet. worksheet.set_column('A:A', 68) worksheet.set_column('B:B', 15) @@ -56,14 +56,14 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'integer', - :criteria => 'between', - :minimum => 1, - :maximum => 10 + validate: 'integer', + criteria: 'between', + minimum: 1, + maximum: 10 } ) # # Example 2. Limiting input to an integer outside a fixed range. @@ -73,14 +73,14 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'integer', - :criteria => 'not between', - :minimum => '=E3', - :maximum => '=F3' + validate: 'integer', + criteria: 'not between', + minimum: '=E3', + maximum: '=F3' } ) # # Example 3. Limiting input to an integer greater than a fixed value. @@ -90,13 +90,13 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'integer', - :criteria => '>', - :value => 0 + validate: 'integer', + criteria: '>', + value: 0 } ) # # Example 4. Limiting input to an integer less than a fixed value. @@ -106,13 +106,13 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'integer', - :criteria => '<', - :value => 10 + validate: 'integer', + criteria: '<', + value: 10 } ) # # Example 5. Limiting input to a decimal in a fixed range. @@ -122,14 +122,14 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'decimal', - :criteria => 'between', - :minimum => 0.1, - :maximum => 0.5 + validate: 'decimal', + criteria: 'between', + minimum: 0.1, + maximum: 0.5 } ) # # Example 6. Limiting input to a value in a dropdown list. @@ -139,12 +139,12 @@ bp = 1 worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'list', - :source => %w[open high close] + validate: 'list', + source: %w[open high close] } ) # # Example 6. Limiting input to a value in a dropdown list. @@ -154,12 +154,12 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'list', - :source => '=$E$4:$G$4' + validate: 'list', + source: '=$E$4:$G$4' } ) # # Example 7. Limiting input to a date in a fixed range. @@ -169,14 +169,14 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'date', - :criteria => 'between', - :minimum => '2008-01-01T', - :maximum => '2008-12-12T' + validate: 'date', + criteria: 'between', + minimum: '2008-01-01T', + maximum: '2008-12-12T' } ) # # Example 8. Limiting input to a time in a fixed range. @@ -186,14 +186,14 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'time', - :criteria => 'between', - :minimum => 'T06:00', - :maximum => 'T12:00' + validate: 'time', + criteria: 'between', + minimum: 'T06:00', + maximum: 'T12:00' } ) # # Example 9. Limiting input to a string greater than a fixed length. @@ -203,13 +203,13 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'length', - :criteria => '>', - :value => 3 + validate: 'length', + criteria: '>', + value: 3 } ) # # Example 10. Limiting input based on a formula. @@ -219,12 +219,12 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'custom', - :value => '=AND(F5=50,G5=60)' + validate: 'custom', + value: '=AND(F5=50,G5=60)' } ) # # Example 11. Displaying and modify data validation messages. @@ -234,16 +234,16 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'integer', - :criteria => 'between', - :minimum => 1, - :maximum => 100, - :input_title => 'Enter an integer:', - :input_message => 'between 1 and 100' + validate: 'integer', + criteria: 'between', + minimum: 1, + maximum: 100, + input_title: 'Enter an integer:', + input_message: 'between 1 and 100' } ) # # Example 12. Displaying and modify data validation messages. @@ -253,18 +253,18 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'integer', - :criteria => 'between', - :minimum => 1, - :maximum => 100, - :input_title => 'Enter an integer:', - :input_message => 'between 1 and 100', - :error_title => 'Input value is not valid!', - :error_message => 'It should be an integer between 1 and 100' + validate: 'integer', + criteria: 'between', + minimum: 1, + maximum: 100, + input_title: 'Enter an integer:', + input_message: 'between 1 and 100', + error_title: 'Input value is not valid!', + error_message: 'It should be an integer between 1 and 100' } ) # # Example 13. Displaying and modify data validation messages. @@ -274,18 +274,18 @@ worksheet.write(row, 0, txt) worksheet.data_validation( row, 1, { - :validate => 'integer', - :criteria => 'between', - :minimum => 1, - :maximum => 100, - :input_title => 'Enter an integer:', - :input_message => 'between 1 and 100', - :error_title => 'Input value is not valid!', - :error_message => 'It should be an integer between 1 and 100', - :error_type => 'information' + validate: 'integer', + criteria: 'between', + minimum: 1, + maximum: 100, + input_title: 'Enter an integer:', + input_message: 'between 1 and 100', + error_title: 'Input value is not valid!', + error_message: 'It should be an integer between 1 and 100', + error_type: 'information' } ) workbook.close