예제 #1
0
        public XSSFDataValidation(XSSFDataValidationConstraint constraint, CellRangeAddressList regions, CT_DataValidation ctDataValidation)
            : base()
        {

            this.validationConstraint = constraint;
            this.ctDdataValidation = ctDataValidation;
            this.regions = regions;
        }
예제 #2
0
        public XSSFDataValidation(CellRangeAddressList regions, CT_DataValidation ctDataValidation)
            : base()
        {

            this.validationConstraint = GetConstraint(ctDataValidation);
            this.ctDdataValidation = ctDataValidation;
            this.regions = regions;
            this.ctDdataValidation.errorStyle = (ST_DataValidationErrorStyle.stop);
            this.ctDdataValidation.allowBlank = (true);
        }
예제 #3
0
파일: Sheet.cs 프로젝트: vardars/npoi
 public void Set(CT_DataValidation obj)
 {
     formula1Field = obj.formula1Field;
     formula2Field = obj.formula2Field;
     typeField = obj.typeField;
     errorStyleField = obj.errorStyleField;
     imeModeField = obj.imeModeField;
     operatorField = obj.operatorField;
     allowBlankField = obj.allowBlankField;
     showDropDownField = obj.showDropDownField;
     showInputMessageField = obj.showInputMessageField;
     showErrorMessageField = obj.showErrorMessageField;
     errorTitleField = obj.errorTitleField;
     errorField = obj.errorField;
     promptTitleField = obj.promptTitleField;
     promptField = obj.promptField;
     sqrefField = obj.sqrefField;
 }
예제 #4
0
파일: Sheet.cs 프로젝트: vardars/npoi
 public static CT_DataValidation Parse(XmlNode node, XmlNamespaceManager namespaceManager)
 {
     if (node == null)
         return null;
     CT_DataValidation ctObj = new CT_DataValidation();
     if (node.Attributes["type"] != null)
         ctObj.type = (ST_DataValidationType)Enum.Parse(typeof(ST_DataValidationType), node.Attributes["type"].Value);
     if (node.Attributes["errorStyle"] != null)
         ctObj.errorStyle = (ST_DataValidationErrorStyle)Enum.Parse(typeof(ST_DataValidationErrorStyle), node.Attributes["errorStyle"].Value);
     if (node.Attributes["imeMode"] != null)
         ctObj.imeMode = (ST_DataValidationImeMode)Enum.Parse(typeof(ST_DataValidationImeMode), node.Attributes["imeMode"].Value);
     if (node.Attributes["operator"] != null)
         ctObj.@operator = (ST_DataValidationOperator)Enum.Parse(typeof(ST_DataValidationOperator), node.Attributes["operator"].Value);
     ctObj.allowBlank = XmlHelper.ReadBool(node.Attributes["allowBlank"]);
     ctObj.showDropDown = XmlHelper.ReadBool(node.Attributes["showDropDown"]);
     ctObj.showInputMessage = XmlHelper.ReadBool(node.Attributes["showInputMessage"]);
     ctObj.showErrorMessage = XmlHelper.ReadBool(node.Attributes["showErrorMessage"]);
     ctObj.errorTitle = XmlHelper.ReadString(node.Attributes["errorTitle"]);
     ctObj.error = XmlHelper.ReadString(node.Attributes["error"]);
     ctObj.promptTitle = XmlHelper.ReadString(node.Attributes["promptTitle"]);
     ctObj.prompt = XmlHelper.ReadString(node.Attributes["prompt"]);
     ctObj.sqref = XmlHelper.ReadString(node.Attributes["sqref"]);
     foreach (XmlNode childNode in node.ChildNodes)
     {
         if (childNode.LocalName == "formula1")
             ctObj.formula1 = childNode.InnerText;
         else if (childNode.LocalName == "formula2")
             ctObj.formula2 = childNode.InnerText;
     }
     return ctObj;
 }
예제 #5
0
파일: Sheet.cs 프로젝트: vardars/npoi
 public CT_DataValidation AddNewDataValidation()
 {
     if (this.dataValidationField == null)
         this.dataValidationField = new List<CT_DataValidation>();
     CT_DataValidation dv = new CT_DataValidation();
     this.dataValidationField.Add(dv);
     this.countField++;
     return dv;
 }
예제 #6
0
파일: Sheet.cs 프로젝트: qljiong/npoi
 public CT_DataValidation AddNewDataValidation()
 {
     CT_DataValidation dv = new CT_DataValidation();
     this.dataValidationField.Add(dv);
     this.countField++;
     return dv;
 }
예제 #7
0
 private XSSFDataValidationConstraint GetConstraint(CT_DataValidation ctDataValidation)
 {
     XSSFDataValidationConstraint constraint = null;
     String formula1 = ctDataValidation.formula1;
     String formula2 = ctDataValidation.formula2;
     ST_DataValidationOperator operator1 = ctDataValidation.@operator;
     ST_DataValidationType type = ctDataValidation.type;
     int validationType = XSSFDataValidation.validationTypeReverseMappings[type];
     int operatorType = XSSFDataValidation.operatorTypeReverseMappings[operator1];
     constraint = new XSSFDataValidationConstraint(validationType, operatorType, formula1, formula2);
     return constraint;
 }
예제 #8
0
        /* (non-Javadoc)
         * @see NPOI.ss.usermodel.DataValidationHelper#CreateValidation(NPOI.ss.usermodel.DataValidationConstraint, NPOI.ss.util.CellRangeAddressList)
         */
        public IDataValidation CreateValidation(IDataValidationConstraint constraint, CellRangeAddressList cellRangeAddressList)
        {
            XSSFDataValidationConstraint dataValidationConstraint = (XSSFDataValidationConstraint)constraint;
            CT_DataValidation newDataValidation = new CT_DataValidation();

            int validationType = constraint.GetValidationType();
            switch (validationType)
            {
                case ValidationType.LIST:
                    newDataValidation.type = (ST_DataValidationType.list);
                    newDataValidation.formula1 = (constraint.Formula1);
                    break;
                case ValidationType.ANY:
                    newDataValidation.type = ST_DataValidationType.none;
                    break;
                case ValidationType.TEXT_LENGTH:
                    newDataValidation.type = ST_DataValidationType.textLength;
                    break;
                case ValidationType.DATE:
                    newDataValidation.type = ST_DataValidationType.date;
                    break;
                case ValidationType.INTEGER:
                    newDataValidation.type = ST_DataValidationType.whole;
                    break;
                case ValidationType.DECIMAL:
                    newDataValidation.type = ST_DataValidationType.@decimal;
                    break;
                case ValidationType.TIME:
                    newDataValidation.type = ST_DataValidationType.time;
                    break;
                case ValidationType.FORMULA:
                    newDataValidation.type = ST_DataValidationType.custom;
                    break;
                default:
                    newDataValidation.type = ST_DataValidationType.none;
                    break;
            }

            if (validationType != ValidationType.ANY && validationType != ValidationType.LIST)
            {
                newDataValidation.@operator = ST_DataValidationOperator.between;
                if(XSSFDataValidation.operatorTypeMappings.ContainsKey(constraint.Operator))
                newDataValidation.@operator = XSSFDataValidation.operatorTypeMappings[constraint.Operator];
                if (constraint.Formula1 != null)
                {
                    newDataValidation.formula1 = (constraint.Formula1);
                }
                if (constraint.Formula2 != null)
                {
                    newDataValidation.formula2 = (constraint.Formula2);
                }
            }

            CellRangeAddress[] cellRangeAddresses = cellRangeAddressList.CellRangeAddresses;
            List<String> sqref = new List<String>();
            for (int i = 0; i < cellRangeAddresses.Length; i++)
            {
                CellRangeAddress cellRangeAddress = cellRangeAddresses[i];
                sqref.Add(cellRangeAddress.FormatAsString());
            }
            newDataValidation.sqref = sqref;

            return new XSSFDataValidation(dataValidationConstraint, cellRangeAddressList, newDataValidation);
        }
예제 #9
0
 public XSSFDataValidation(CellRangeAddressList regions, CT_DataValidation ctDataValidation)
     : this(GetConstraint(ctDataValidation), regions, ctDataValidation)
 {
 }