cfsimplicity / spreadsheet-cfml

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

Date Validation #356

Closed dlineg4 closed 6 months ago

dlineg4 commented 7 months ago

First off. Thank you. This library is fantastic.

The addition of the newDataValidation/addDataValidation is fantastic. I'm curious is there a way to do Date Validation of a cell?

Thanks.

cfsimplicity commented 7 months ago

Appreciate your comments.

Currently the library's data validation functionality only supports "lists", i.e. drop-downs of valid items.

But POI does allow other types of constraint including dates so this could be an enhancement.

cfsimplicity commented 7 months ago

@dlineg4 I'm assuming you mean something like this:

validation = s.newDataValidation()
  .onCells( cellRange )
  .withMinDate( ParseDateTime( "1 January 2023" ) )
  .withMaxDate( ParseDateTime( "31 December 2023" ) )
  .withErrorMessage( "Please enter a date in 2023" )
  .addToWorkbook( workbook );

Could you confirm this is what you have in mind?

dlineg4 commented 7 months ago

@cfsimplicity Yeah, that would be pretty great. For other future validations (like Decimals and Whole Numbers, etc) would you predict that it would follow a similar format for you proposal for Dates? For example something like this?

validation = s.newDataValidation()
  .onCells( cellRange )
  .withMinWholeNumber( 0 )
  .withMaxWholeNumber( 50000 )
  .withErrorMessage( "Please enter a number between 0 and 50000" )
  .addToWorkbook( workbook );

Thanks.

image

cfsimplicity commented 7 months ago

POI does support all of those types and I did envisage adding others in due course. I'll probably only add dates and numbers for now though.

I think I'd use "Integer" rather than "Whole number" - more appropriate in a programming context I think.

dlineg4 commented 7 months ago

Dates would be much appreciated.

Thanks again. I'll keep on the lookout.

cfsimplicity commented 6 months ago

https://github.com/cfsimplicity/spreadsheet-cfml/issues/364