Esempio n. 1
0
 /// <summary>
 /// Check whether or not a specified range is contained by this range.
 /// </summary>
 /// <param name="range">Range position to be checked.</param>
 /// <returns>True if the specified range is contained by this range; Otherwise return false.</returns>
 public bool Contains(ReferenceRange range)
 {
     return(this.startCell.InternalRow <= range.startCell.InternalRow &&
            this.startCell.InternalCol <= range.startCell.InternalCol &&
            this.endCell.InternalRow >= range.endCell.InternalRow &&
            this.endCell.InternalCol >= range.endCell.InternalCol);
 }
Esempio n. 2
0
        /// <summary>
        /// Try get range by specified address or range name.
        /// </summary>
        /// <param name="addressOrName">Address or range name used to find range on worksheet.</param>
        /// <param name="range">Range that was found by specified address or name on worksheet.</param>
        /// <returns>True if range was found; Otherwise return false.</returns>
        public ReferenceRange TryGetRangeByAddressOrName(string addressOrName)
        {
            ReferenceRange range = null;

            if (RangePosition.IsValidAddress(addressOrName))
            {
                range = new ReferenceRange(this, addressOrName);
            }
            else if (NamedRange.IsValidName(addressOrName))
            {
                NamedRange namedRange;

                if (this.registeredNamedRanges.TryGetValue(addressOrName, out namedRange))
                {
                    range = new ReferenceRange(namedRange.Worksheet, namedRange.Position);
                }
            }
            return(range);
        }
Esempio n. 3
0
 private static void AddCellReferenceIntoList(List <ReferenceRange> referencedRanges, ReferenceRange range)
 {
     if (referencedRanges.All(rr => rr.Worksheet == range.Worksheet && !rr.Contains(range)))
     {
         referencedRanges.Add(range);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Check whether or not that the specified range intersects with this range.
 /// </summary>
 /// <param name="range">The range to be checked.</param>
 /// <returns>True if specified range intersects with this range.</returns>
 public bool IntersectWith(ReferenceRange range)
 {
     return(this.IntersectWith(range.Position));
 }