Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date Validation #356

Closed
dlineg4 opened this issue Feb 8, 2024 · 6 comments
Closed

Date Validation #356

dlineg4 opened this issue Feb 8, 2024 · 6 comments
Assignees
Milestone

Comments

@dlineg4
Copy link

dlineg4 commented Feb 8, 2024

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
Copy link
Owner

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
Copy link
Owner

@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
Copy link
Author

dlineg4 commented Feb 10, 2024

@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
Copy link
Owner

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
Copy link
Author

dlineg4 commented Feb 10, 2024

Dates would be much appreciated.

Thanks again. I'll keep on the lookout.

@cfsimplicity cfsimplicity added this to the 4.0.0 milestone Mar 5, 2024
@cfsimplicity
Copy link
Owner

#364

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants