Skip to content

Instantly share code, notes, and snippets.

@lporras
Created January 5, 2018 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lporras/ee1305ce6ea02ece2ebc7d83b2d2d345 to your computer and use it in GitHub Desktop.
Save lporras/ee1305ce6ea02ece2ebc7d83b2d2d345 to your computer and use it in GitHub Desktop.
DataValidation Example with write_xlsx Gem
require 'write_xlsx'
workbook = WriteXLSX.new('write_xlsx_example.xlsx')
dropdownSheet = workbook.add_worksheet('DropDown Values')
dropdownSheet.write_row(0,0,['open', 'high', 'close'])
dropdownSheet.protect('password')
worksheet = workbook.add_worksheet
worksheet.data_validation('A1:A100',
{
:validate => 'list',
#:value => ['open', 'high', 'close'],
:value => "'DropDown Values'!A$1:C$1",
#:input_title => 'Input an integer:',
:input_message => 'Choose the value from the dropdown',
:error_message => 'Please use the dropdown selector to choose the value'
})
dropdownSheet.hide
worksheet.set_first_sheet
worksheet.activate
workbook.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment