コード例 #1
0
        /// <summary>
        /// Allow date values.
        /// </summary>
        /// <param name="DataOperator">The type of operation.</param>
        /// <param name="DataValue">The data value. Any valid date formatted value is fine. It is suggested to just copy the value you have in Excel interface.</param>
        /// <param name="IgnoreBlank">True if blanks are ignored. False otherwise.</param>
        public void AllowDate(SLDataValidationSingleOperandValues DataOperator, string DataValue, bool IgnoreBlank)
        {
            this.Type     = DataValidationValues.Date;
            this.Operator = this.TranslateOperatorValues(DataOperator);

            DateTime dt;

            if (DataValue.StartsWith("="))
            {
                this.Formula1 = DataValue.Substring(1);
            }
            else
            {
                if (DateTime.TryParse(DataValue, out dt))
                {
                    this.Formula1 = SLTool.CalculateDaysFromEpoch(dt, this.Date1904).ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    // 1 Jan 1900
                    this.Formula1 = "1";
                }
            }

            this.Formula2   = string.Empty;
            this.AllowBlank = IgnoreBlank;
        }
コード例 #2
0
 /// <summary>
 /// Allow date values.
 /// </summary>
 /// <param name="DataOperator">The type of operation.</param>
 /// <param name="DataValue">The data value. Any valid date formatted value is fine. It is suggested to just copy the value you have in Excel interface.</param>
 /// <param name="IgnoreBlank">True if blanks are ignored. False otherwise.</param>
 public void AllowDate(SLDataValidationSingleOperandValues DataOperator, DateTime DataValue, bool IgnoreBlank)
 {
     this.Type       = DataValidationValues.Date;
     this.Operator   = this.TranslateOperatorValues(DataOperator);
     this.Formula1   = SLTool.CalculateDaysFromEpoch(DataValue, this.Date1904).ToString(CultureInfo.InvariantCulture);
     this.Formula2   = string.Empty;
     this.AllowBlank = IgnoreBlank;
 }
コード例 #3
0
 /// <summary>
 /// Allow date values.
 /// </summary>
 /// <param name="IsBetween">True if the data is between 2 values. False otherwise.</param>
 /// <param name="Minimum">The minimum value.</param>
 /// <param name="Maximum">The maximum value.</param>
 /// <param name="IgnoreBlank">True if blanks are ignored. False otherwise.</param>
 public void AllowDate(bool IsBetween, DateTime Minimum, DateTime Maximum, bool IgnoreBlank)
 {
     this.Type       = DataValidationValues.Date;
     this.Operator   = IsBetween ? DataValidationOperatorValues.Between : DataValidationOperatorValues.NotBetween;
     this.Formula1   = SLTool.CalculateDaysFromEpoch(Minimum, this.Date1904).ToString(CultureInfo.InvariantCulture);
     this.Formula2   = SLTool.CalculateDaysFromEpoch(Maximum, this.Date1904).ToString(CultureInfo.InvariantCulture);
     this.AllowBlank = IgnoreBlank;
 }
コード例 #4
0
        /// <summary>
        /// Allow date values.
        /// </summary>
        /// <param name="IsBetween">True if the data is between 2 values. False otherwise.</param>
        /// <param name="Minimum">The minimum value. Any valid date formatted value is fine. It is suggested to just copy the value you have in Excel interface.</param>
        /// <param name="Maximum">The maximum value. Any valid date formatted value is fine. It is suggested to just copy the value you have in Excel interface.</param>
        /// <param name="IgnoreBlank">True if blanks are ignored. False otherwise.</param>
        public void AllowDate(bool IsBetween, string Minimum, string Maximum, bool IgnoreBlank)
        {
            this.Type     = DataValidationValues.Date;
            this.Operator = IsBetween ? DataValidationOperatorValues.Between : DataValidationOperatorValues.NotBetween;

            DateTime dt;

            if (Minimum.StartsWith("="))
            {
                this.Formula1 = Minimum.Substring(1);
            }
            else
            {
                if (DateTime.TryParse(Minimum, out dt))
                {
                    this.Formula1 = SLTool.CalculateDaysFromEpoch(dt, this.Date1904).ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    // 1 Jan 1900
                    this.Formula1 = "1";
                }
            }

            if (Maximum.StartsWith("="))
            {
                this.Formula2 = Maximum.Substring(1);
            }
            else
            {
                if (DateTime.TryParse(Maximum, out dt))
                {
                    this.Formula2 = SLTool.CalculateDaysFromEpoch(dt, this.Date1904).ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    // 1 Jan 1900
                    this.Formula2 = "1";
                }
            }

            this.AllowBlank = IgnoreBlank;
        }