Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Add Data Validation in Excel in Java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Data validation is a very useful feature in MS Excel which allows us to restrict the type of data or values that users enter into cells. In this article, I will introduce how to add data validation in an Excel file by using Free Spire.XLS for Java library.

Dependencies

First of all, you need to add needed dependencies for including Free Spire.XLS for Java into your Java project. There are two ways to do that.
If you use maven, you need to add the following code to your project’s pom.xml file.

For non-maven projects, download Free Spire.XLS for Java pack from this website and add Spire.Xls.jar in the lib folder into your project as a dependency.

Data validation types

Free Spire.XLS for Java library supports the following data validation types:

  • Whole number
  • Decimal
  • Drop down list
  • Time
  • Text length
  • Date
  • Custom
  • Any

  • The following examples elaborate on how to add whole number, decimal, drop down list, time and text length data validations to Excel files by using Free Spire.XLS for Java library.

    Add whole number data validation

    This type of validation allows users to enter only whole numbers within a specified range into the validated cells. In the following example, the user is restricted to enter a number between 10 and 100.



    Add decimal data validation

    This type of validation allows users to enter decimal numbers within a specified range into the validated cells. In the following example, the user is restricted to enter a decimal value between 3 and 6.



    Add drop down list data validation

    This type of validation allows the user to enter or select values from a drop-down list.



    Add time data validation

    This type of validation allows users to enter times within a specified range into the validated cells. In the following example, the user is restricted to enter a time between 09:00 AM to 18:00 PM.



    Add text length data validation

    This type of validation allows users to enter text values of a specified length into the validated cells. In the following example, the user is restricted to enter a string value with no more than 5 characters.



     
    So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
      Bookmark Topic Watch Topic
    • New Topic