/// <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) { Type = DataValidationValues.Date; Operator = TranslateOperatorValues(DataOperator); DateTime dt; if (DataValue.StartsWith("=")) { Formula1 = DataValue.Substring(1); } else { if (DateTime.TryParse(DataValue, out dt)) { Formula1 = SLTool.CalculateDaysFromEpoch(dt, Date1904).ToString(CultureInfo.InvariantCulture); } else { Formula1 = "1"; } } Formula2 = string.Empty; AllowBlank = IgnoreBlank; }
/// <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) { Type = DataValidationValues.Date; Operator = TranslateOperatorValues(DataOperator); Formula1 = SLTool.CalculateDaysFromEpoch(DataValue, Date1904).ToString(CultureInfo.InvariantCulture); Formula2 = string.Empty; AllowBlank = IgnoreBlank; }
/// <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) { Type = DataValidationValues.Date; Operator = IsBetween ? DataValidationOperatorValues.Between : DataValidationOperatorValues.NotBetween; Formula1 = SLTool.CalculateDaysFromEpoch(Minimum, Date1904).ToString(CultureInfo.InvariantCulture); Formula2 = SLTool.CalculateDaysFromEpoch(Maximum, Date1904).ToString(CultureInfo.InvariantCulture); AllowBlank = IgnoreBlank; }
/// <summary> /// Set the corresponding value axis to cross this axis at a given date. This is for date axis. WARNING: Internally, this is used for category, date and value axes. Remember to set the axis type. /// </summary> /// <param name="DateToBeCrossed">Date to cross at.</param> public void SetOtherAxisCrossing(DateTime DateToBeCrossed) { this.OtherAxisIsCrosses = false; this.OtherAxisCrosses = C.CrossesValues.AutoZero; this.OtherAxisCrossesAt = SLTool.CalculateDaysFromEpoch(DateToBeCrossed, this.Date1904); // the given date is before the epochs (1900 or 1904). // Just set to whatever the current epoch is being used. if (this.OtherAxisCrossesAt < 0.0) { this.OtherAxisCrossesAt = this.Date1904 ? 0.0 : 1.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) { Type = DataValidationValues.Date; Operator = IsBetween ? DataValidationOperatorValues.Between : DataValidationOperatorValues.NotBetween; DateTime dt; if (Minimum.StartsWith("=")) { Formula1 = Minimum.Substring(1); } else { if (DateTime.TryParse(Minimum, out dt)) { Formula1 = SLTool.CalculateDaysFromEpoch(dt, Date1904).ToString(CultureInfo.InvariantCulture); } else { Formula1 = "1"; } } if (Maximum.StartsWith("=")) { Formula2 = Maximum.Substring(1); } else { if (DateTime.TryParse(Maximum, out dt)) { Formula2 = SLTool.CalculateDaysFromEpoch(dt, Date1904).ToString(CultureInfo.InvariantCulture); } else { Formula2 = "1"; } } AllowBlank = IgnoreBlank; }