Package org.openxmlformats.schemas.spreadsheetml.x2006.main

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDataValidation


    }

    private float getColumnWidthInPixels(int columnIndex){
        XSSFSheet sheet = (XSSFSheet)getDrawing().getParent();

        CTCol col = sheet.getColumnHelper().getColumn(columnIndex, false);
        double numChars = col == null || !col.isSetWidth() ? DEFAULT_COLUMN_WIDTH : col.getWidth();

        return (float)numChars*XSSFWorkbook.DEFAULT_CHARACTER_WIDTH;
    }
View Full Code Here


    CTDataValidations dataValidations = worksheet.getDataValidations();
    if( dataValidations==null ) {
      dataValidations = worksheet.addNewDataValidations();
    }
    int currentCount = dataValidations.sizeOfDataValidationArray();
        CTDataValidation newval = dataValidations.addNewDataValidation();
    newval.set(xssfDataValidation.getCtDdataValidation());
    dataValidations.setCount(currentCount + 1);

  }
View Full Code Here

    CTDataValidations dataValidations = worksheet.getDataValidations();
    if( dataValidations==null ) {
      dataValidations = worksheet.addNewDataValidations();
    }
    int currentCount = dataValidations.sizeOfDataValidationArray();
        CTDataValidation newval = dataValidations.addNewDataValidation();
    newval.set(xssfDataValidation.getCtDdataValidation());
    dataValidations.setCount(currentCount + 1);

  }
View Full Code Here

        CTDataValidations dataValidations = worksheet.getDataValidations();
        if( dataValidations==null ) {
            dataValidations = worksheet.addNewDataValidations();
        }
        int currentCount = dataValidations.sizeOfDataValidationArray();
        CTDataValidation newval = dataValidations.addNewDataValidation();
        newval.set(xssfDataValidation.getCtDdataValidation());
        dataValidations.setCount(currentCount + 1);

    }
View Full Code Here

    CTDataValidations dataValidations = worksheet.getDataValidations();
    if( dataValidations==null ) {
      dataValidations = worksheet.addNewDataValidations();
    }
    int currentCount = dataValidations.sizeOfDataValidationArray();
        CTDataValidation newval = dataValidations.addNewDataValidation();
    newval.set(xssfDataValidation.getCtDdataValidation());
    dataValidations.setCount(currentCount + 1);

  }
View Full Code Here

    CTDataValidations dataValidations = worksheet.getDataValidations();
    if( dataValidations==null ) {
      dataValidations = worksheet.addNewDataValidations();
    }
    int currentCount = dataValidations.getDataValidationArray().length;
        CTDataValidation newval = dataValidations.addNewDataValidation();
    newval.set(xssfDataValidation.getCtDdataValidation());
    dataValidations.setCount(currentCount + 1);

  }
View Full Code Here

    CTDataValidations dataValidations = worksheet.getDataValidations();
    if( dataValidations==null ) {
      dataValidations = worksheet.addNewDataValidations();
    }
    int currentCount = dataValidations.getDataValidationList().size();
        CTDataValidation newval = dataValidations.addNewDataValidation();
    newval.set(xssfDataValidation.getCtDdataValidation());
    dataValidations.setCount(currentCount + 1);

  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.poi.ss.usermodel.DataValidationHelper#createValidation(org.apache.poi.ss.usermodel.DataValidationConstraint, org.apache.poi.ss.util.CellRangeAddressList)
   */
  public DataValidation createValidation(DataValidationConstraint constraint, CellRangeAddressList cellRangeAddressList) {
    XSSFDataValidationConstraint dataValidationConstraint = (XSSFDataValidationConstraint)constraint;
    CTDataValidation newDataValidation = CTDataValidation.Factory.newInstance();

    int validationType = constraint.getValidationType();
    switch(validationType) {
      case DataValidationConstraint.ValidationType.LIST:
          newDataValidation.setType(STDataValidationType.LIST);
        newDataValidation.setFormula1(constraint.getFormula1());       
          break;
      case DataValidationConstraint.ValidationType.ANY:       
        newDataValidation.setType(STDataValidationType.NONE);       
        break;
      case DataValidationConstraint.ValidationType.TEXT_LENGTH:
        newDataValidation.setType(STDataValidationType.TEXT_LENGTH);
        break;       
      case DataValidationConstraint.ValidationType.DATE:
        newDataValidation.setType(STDataValidationType.DATE);
        break;       
      case DataValidationConstraint.ValidationType.INTEGER:
        newDataValidation.setType(STDataValidationType.WHOLE);
        break;       
      case DataValidationConstraint.ValidationType.DECIMAL:
        newDataValidation.setType(STDataValidationType.DECIMAL);
        break;       
      case DataValidationConstraint.ValidationType.TIME:
        newDataValidation.setType(STDataValidationType.TIME);
        break;
      case DataValidationConstraint.ValidationType.FORMULA:
        newDataValidation.setType(STDataValidationType.CUSTOM);
        break;
      default:
        newDataValidation.setType(STDataValidationType.NONE);       
    }
   
    if (validationType!=ValidationType.ANY && validationType!=ValidationType.LIST) {
            STDataValidationOperator.Enum op = XSSFDataValidation.operatorTypeMappings.get(constraint.getOperator());
      if(op != null) {
                newDataValidation.setOperator(op);
            }
      if (constraint.getFormula1() != null) {
        newDataValidation.setFormula1(constraint.getFormula1());
      }
      if (constraint.getFormula2() != null) {
        newDataValidation.setFormula2(constraint.getFormula2());
      }
    }
   
    CellRangeAddress[] cellRangeAddresses = cellRangeAddressList.getCellRangeAddresses();
    List<String> sqref = new ArrayList<String>();
    for (int i = 0; i < cellRangeAddresses.length; i++) {
      CellRangeAddress cellRangeAddress = cellRangeAddresses[i];
      sqref.add(cellRangeAddress.formatAsString());
    }
    newDataValidation.setSqref(sqref);
   
    return new XSSFDataValidation(dataValidationConstraint,cellRangeAddressList,newDataValidation);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.poi.ss.usermodel.DataValidationHelper#createValidation(org.apache.poi.ss.usermodel.DataValidationConstraint, org.apache.poi.ss.util.CellRangeAddressList)
   */
  public DataValidation createValidation(DataValidationConstraint constraint, CellRangeAddressList cellRangeAddressList) {
    XSSFDataValidationConstraint dataValidationConstraint = (XSSFDataValidationConstraint)constraint;
    CTDataValidation newDataValidation = CTDataValidation.Factory.newInstance();

    int validationType = constraint.getValidationType();
    switch(validationType) {
      case DataValidationConstraint.ValidationType.LIST:
          newDataValidation.setType(STDataValidationType.LIST);
        newDataValidation.setFormula1(constraint.getFormula1());       
          break;
      case DataValidationConstraint.ValidationType.ANY:       
        newDataValidation.setType(STDataValidationType.NONE);       
        break;
      case DataValidationConstraint.ValidationType.TEXT_LENGTH:
        newDataValidation.setType(STDataValidationType.TEXT_LENGTH);
        break;       
      case DataValidationConstraint.ValidationType.DATE:
        newDataValidation.setType(STDataValidationType.DATE);
        break;       
      case DataValidationConstraint.ValidationType.INTEGER:
        newDataValidation.setType(STDataValidationType.WHOLE);
        break;       
      case DataValidationConstraint.ValidationType.DECIMAL:
        newDataValidation.setType(STDataValidationType.DECIMAL);
        break;       
      case DataValidationConstraint.ValidationType.TIME:
        newDataValidation.setType(STDataValidationType.TIME);
        break;
      case DataValidationConstraint.ValidationType.FORMULA:
        newDataValidation.setType(STDataValidationType.CUSTOM);
        break;
      default:
        newDataValidation.setType(STDataValidationType.NONE);       
    }
   
    if (validationType!=ValidationType.ANY && validationType!=ValidationType.LIST) {
      newDataValidation.setOperator(XSSFDataValidation.operatorTypeMappings.get(constraint.getOperator()));     
      if (constraint.getFormula1() != null) {
        newDataValidation.setFormula1(constraint.getFormula1());
      }
      if (constraint.getFormula2() != null) {
        newDataValidation.setFormula2(constraint.getFormula2());
      }
    }
   
    CellRangeAddress[] cellRangeAddresses = cellRangeAddressList.getCellRangeAddresses();
    List<String> sqref = new ArrayList<String>();
    for (int i = 0; i < cellRangeAddresses.length; i++) {
      CellRangeAddress cellRangeAddress = cellRangeAddresses[i];
      sqref.add(cellRangeAddress.formatAsString());
    }
    newDataValidation.setSqref(sqref);
   
    return new XSSFDataValidation(dataValidationConstraint,cellRangeAddressList,newDataValidation);
  }
View Full Code Here

        CTDataValidations dataValidations = worksheet.getDataValidations();
        if( dataValidations==null ) {
            dataValidations = worksheet.addNewDataValidations();
        }
        int currentCount = dataValidations.sizeOfDataValidationArray();
        CTDataValidation newval = dataValidations.addNewDataValidation();
        newval.set(xssfDataValidation.getCtDdataValidation());
        dataValidations.setCount(currentCount + 1);

    }
View Full Code Here

TOP

Related Classes of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDataValidation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.