Data Validation List on Excel Sheet Using JExcel APIs.

Data Validation List on Excel Sheet Using JExcel APIs.

Previous Home Next

 

In this tutorial we will see how to create a data Validation List on Excel Sheet Using JExcel APIs.

For creating a data validation list we have use the jxl.write.WritableCellFeatures class. This class contains the setDataValidationList() method which can be used to create a data validation list.
 For creating a data validation list we have use the 
jxl.write.WritableCellFeatures class. This class contains the 
setDataValidationList() method which can be used to create a data 
validation list. The following code snippet will help you out to create a DataValidationList inside an excel sheet,

WritableWorkbook workbook=Workbook.createWorkbook(new File("F:/JAVA PROJECTS/Jexcel/src/r4r/co/in/firstsheet.xls"));
WritableSheet sheet=workbook.createSheet("mysheet", 0);
ArrayList al=new ArrayList();       // creating an ArrayList
al.add("r4r");                      // adding object to the list
al.add("tutorials");
al.add("development");
al.add("shashi");
al.add("software engineer");
al.add("Validation list");
WritableCellFeatures wcff=new WritableCellFeatures();        // created the object of the WritableCellFeatures class
wcff.setComment("This is a comment", 1, 2);                  // setting a comment
wcff.setDataValidationList(al);                              // we have set a data validation list by using the method on the WritableCellFeatures object
Label lbl=new Label(7,7,(String)al.);                        // created a label which selects the Validation list by default in the sheet 
lbl.setCellFeatures(wcff);                                    // set the cell features to the label object
     


 

Previous Home Next