Exemplo n.º 1
0
 public void AddDataValidation(DVRecord dvRecord)
 {
     _validationList.Add(dvRecord);
     _headerRec.SetDVRecNo(_validationList.Count);
 }
Exemplo n.º 2
0
 internal static DVConstraint CreateDVConstraint(DVRecord dvRecord, IFormulaRenderingWorkbook book)
 {
     switch (dvRecord.DataType)
     {
         case ValidationType.ANY:
             return new DVConstraint(ValidationType.ANY, dvRecord.ConditionOperator, null, null, double.NaN, double.NaN, null);
         case ValidationType.INTEGER:
         case ValidationType.DECIMAL:
         case ValidationType.DATE:
         case ValidationType.TIME:
         case ValidationType.TEXT_LENGTH:
             FormulaValuePair pair1 = toFormulaString(dvRecord.Formula1, book);
             FormulaValuePair pair2 = toFormulaString(dvRecord.Formula2, book);
             return new DVConstraint(dvRecord.DataType, dvRecord.ConditionOperator, pair1.formula(),
                     pair2.formula(), pair1.Value, pair2.Value, null);
         case ValidationType.LIST:
             if (dvRecord.ListExplicitFormula)
             {
                 String values = toFormulaString(dvRecord.Formula1, book).AsString();
                 if (values.StartsWith("\""))
                 {
                     values = values.Substring(1);
                 }
                 if (values.EndsWith("\""))
                 {
                     values = values.Substring(0, values.Length - 1);
                 }
                 String[] explicitListValues = values.Split("\0".ToCharArray());
                 return CreateExplicitListConstraint(explicitListValues);
             }
             else
             {
                 String listFormula = toFormulaString(dvRecord.Formula1, book).AsString();
                 return CreateFormulaListConstraint(listFormula);
             }
         case ValidationType.FORMULA:
             return CreateCustomFormulaConstraint(toFormulaString(dvRecord.Formula1, book).AsString());
         default:
             throw new InvalidOperationException(string.Format("validationType={0}", dvRecord.DataType));
     }
 }