protected void createEmpty() { field_3_enclosing_cell_range = new CellRangeAddress(0, 0, 0, 0); field_4_cell_ranges = new CellRangeAddressList(); } protected void read(RecordInputStream in) {
public CellRangeAddressList copy() { CellRangeAddressList result = new CellRangeAddressList(); int nItems = _list.size(); for (int k = 0; k < nItems; k++) { CellRangeAddress region = _list.get(k); result.addCellRangeAddress(region.copy()); } return result; } public CellRangeAddress[] getCellRangeAddresses() {
/** * Set cell ranges list to a single cell range and * modify the enclosing cell range accordingly. * @param cellRanges - list of CellRange objects */ public void setCellRanges(CellRangeAddress[] cellRanges) { if(cellRanges == null) { throw new IllegalArgumentException("cellRanges must not be null"); } CellRangeAddressList cral = new CellRangeAddressList(); CellRangeAddress enclosingRange = null; for (CellRangeAddress cr : cellRanges) { enclosingRange = CellRangeUtil.createEnclosingCellRange(cr, enclosingRange); cral.addCellRangeAddress(cr); } field_3_enclosing_cell_range = enclosingRange; field_4_cell_ranges = cral; }
protected void read(RecordInputStream in) { field_1_numcf = in.readShort(); field_2_need_recalculation_and_id = in.readShort(); field_3_enclosing_cell_range = new CellRangeAddress(in); field_4_cell_ranges = new CellRangeAddressList(in); }
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet realSheet = workbook.createSheet("Sheet xls"); HSSFSheet hidden = workbook.createSheet("hidden"); for (int i = 0, length= countryName.length; i < length; i++) { String name = countryName[i]; HSSFRow row = hidden.createRow(i); HSSFCell cell = row.createCell(0); cell.setCellValue(name); } Name namedCell = workbook.createName(); namedCell.setNameName("hidden"); namedCell.setRefersToFormula("hidden!$A$1:$A$" + countryName.length); DVConstraint constraint = DVConstraint.createFormulaListConstraint("hidden"); CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0); HSSFDataValidation validation = new HSSFDataValidation(addressList, constraint); workbook.setSheetHidden(1, true); realSheet.addValidationData(validation); FileOutputStream stream = new FileOutputStream("c:\\range.xls"); workbook.write(stream); stream.close();
@Override public List<XSSFDataValidation> getDataValidations() { List<XSSFDataValidation> xssfValidations = new ArrayList<>(); CTDataValidations dataValidations = this.worksheet.getDataValidations(); if( dataValidations!=null && dataValidations.getCount() > 0 ) { for (CTDataValidation ctDataValidation : dataValidations.getDataValidationArray()) { CellRangeAddressList addressList = new CellRangeAddressList(); @SuppressWarnings("unchecked") List<String> sqref = ctDataValidation.getSqref(); for (String stRef : sqref) { String[] regions = stRef.split(" "); for (String region : regions) { String[] parts = region.split(":"); CellReference begin = new CellReference(parts[0]); CellReference end = parts.length > 1 ? new CellReference(parts[1]) : begin; CellRangeAddress cellRangeAddress = new CellRangeAddress(begin.getRow(), end.getRow(), begin.getCol(), end.getCol()); addressList.addCellRangeAddress(cellRangeAddress); } } XSSFDataValidation xssfDataValidation = new XSSFDataValidation(addressList, ctDataValidation); xssfValidations.add(xssfDataValidation); } } return xssfValidations; }
public DVRecord(RecordInputStream in) { _option_flags = in.readInt(); _promptTitle = readUnicodeString(in); _errorTitle = readUnicodeString(in); _promptText = readUnicodeString(in); _errorText = readUnicodeString(in); int field_size_first_formula = in.readUShort(); _not_used_1 = in.readShort(); // "You may not use unions, intersections or array constants in Data Validation criteria" // read first formula data condition _formula1 = Formula.read(field_size_first_formula, in); int field_size_sec_formula = in.readUShort(); _not_used_2 = in.readShort(); // read sec formula data condition _formula2 = Formula.read(field_size_sec_formula, in); // read cell range address list with all affected ranges _regions = new CellRangeAddressList(in); }
/** Creates new CFHeaderRecord */ public CFHeaderRecord() { field_4_cell_ranges = new CellRangeAddressList(); } public CFHeaderRecord(CellRangeAddress[] regions, int nRules) {
/** Creates new CFHeaderRecord */ public CFHeaderRecord() { field_4_cell_ranges = new CellRangeAddressList(); } public CFHeaderRecord(CellRangeAddress[] regions, int nRules) {
//this might help u CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0); DVConstraint dvConstraint = DVConstraint .createExplicitListConstraint(new String[] { "Ann", "Ben", "Cam" }); DataValidation dataValidation = new HSSFDataValidation(addressList,dvConstraint); dataValidation.setSuppressDropDownArrow(false); sheet.addValidationData(dataValidation);
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Data Validation"); CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0); DVConstraint dvConstraint = DVConstraint.createExplicitListConstraint(new String[]{"10", "20", "30"}); DataValidation dataValidation = new HSSFDataValidation(addressList, dvConstraint); dataValidation.setSuppressDropDownArrow(false); sheet.addValidationData(dataValidation);
protected void createEmpty() { field_3_enclosing_cell_range = new CellRangeAddress(0, 0, 0, 0); field_4_cell_ranges = new CellRangeAddressList(); } protected void read(RecordInputStream in) {
CellRangeAddressList addressList = new CellRangeAddressList(0, 5, 0, 0); DVConstraint dvConstraint = DVConstraint .createExplicitListConstraint(new String[] { "10", "20", "30" }); HSSFDataValidation dataValidation = new HSSFDataValidation(addressList, dvConstraint); dataValidation.setSuppressDropDownArrow(false); sheet.addValidationData(dataValidation);
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet sheet = workbook.createSheet("Data Validation"); XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper(sheet); XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint) dvHelper.createExplicitListConstraint(new String[]{"11", "21", "31"}); CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0); XSSFDataValidation validation = (XSSFDataValidation)dvHelper.createValidation( dvConstraint, addressList); validation.setShowErrorBox(true); sheet.addValidationData(validation);
public CellRangeAddressList copy() { CellRangeAddressList result = new CellRangeAddressList(); int nItems = _list.size(); for (int k = 0; k < nItems; k++) { CellRangeAddress region = _list.get(k); result.addCellRangeAddress(region.copy()); } return result; } public CellRangeAddress[] getCellRangeAddresses() {
public CellRangeAddressList copy() { CellRangeAddressList result = new CellRangeAddressList(); int nItems = _list.size(); for (int k = 0; k < nItems; k++) { CellRangeAddress region = (CellRangeAddress) _list.get(k); result.addCellRangeAddress(region.copy()); } return result; } public CellRangeAddress[] getCellRangeAddresses() {
public CellRangeAddressList copy() { CellRangeAddressList result = new CellRangeAddressList(); int nItems = _list.size(); for (int k = 0; k < nItems; k++) { CellRangeAddress region = (CellRangeAddress) _list.get(k); result.addCellRangeAddress(region.copy()); } return result; } public CellRangeAddress[] getCellRangeAddresses() {
protected void read(RecordInputStream in) { field_1_numcf = in.readShort(); field_2_need_recalculation_and_id = in.readShort(); field_3_enclosing_cell_range = new CellRangeAddress(in); field_4_cell_ranges = new CellRangeAddressList(in); }
public CFHeaderRecord(RecordInputStream in) { field_1_numcf = in.readShort(); field_2_need_recalculation = in.readShort(); field_3_enclosing_cell_range = new CellRangeAddress(in); field_4_cell_ranges = new CellRangeAddressList(in); }
public CFHeaderRecord(RecordInputStream in) { field_1_numcf = in.readShort(); field_2_need_recalculation = in.readShort(); field_3_enclosing_cell_range = new CellRangeAddress(in); field_4_cell_ranges = new CellRangeAddressList(in); }