I am using apache-poi for generating the excel file. I need to make the 4th column read-only and the remaining 2 columns will be editable by the user.
I am using
CellRangeAddressList addressList = new CellRangeAddressList(firstRow, lastRow, firstCol, lastCol);
DVConstraint dvConstraint = DVConstraint.createExplicitListConstraint(new String[] { "ReadOnlyCell" });
HSSFDataValidation dataValidation = new HSSFDataValidation(addressList, dvConstraint);
dataValidation.setSuppressDropDownArrow(true);
dataValidation.setEmptyCellAllowed(false);
dataValidation.createErrorBox("Error", "Cell can not be editable");
spreadsheet.addValidationData(dataValidation);