cfsimplicity / spreadsheet-cfml

Standalone library for working with spreadsheets and CSV in CFML
MIT License
127 stars 36 forks source link

DataValidation & dropdown #300

Closed ivanionut closed 2 years ago

ivanionut commented 2 years ago

hi, is it possible to implement this class in spreadsheet-cfml to have the ability to generate dropdown?

thanks, Ivan

cfsimplicity commented 2 years ago

Hi, I'll take a look. Can you give me a bit more detail on how you might use it?

ivanionut commented 2 years ago

hi Julian, what I want to do are "simple" drop-downs list within a cell or column.

Like this: https://support.microsoft.com/en-us/office/create-a-drop-down-list-7693307a-59ef-400a-b769-c5402dce407b

cfsimplicity commented 2 years ago

Hi Ivan

I've added support for data validations to the develop branch. Could you please download and test it?

Basic usage is as follows:

myWorkbook = spreadsheet.newXlsx();
spreadsheet.newDataValidation()
  .onCells( "A1:C1" )
  .withValues( [ "New York", "London", "Paris" ] ) //an array of valid values
  .addToWorkbook( myWorkbook );

Pulling the values from other cells in the workbook is also supported:

myWorkbook = spreadsheet.newXlsx();
spreadsheet.newDataValidation()
  .onCells( "A1:C1" )
  .withValuesFromSheetName( "cities" )
  .withValuesFromCells( "A1:A3" )
  .addToWorkbook( myWorkbook );

I'll create full documentation on release but meantime the tests provide a bit more detail.

Please let me know if you find any problems or have questions.

ivanionut commented 2 years ago

@cfsimplicity wow, thanks! it works very well!

cfsimplicity commented 2 years ago

OK, great. I'll cut a new release soon.