/// <summary> /// Try get a named range by specified name /// </summary> /// <param name="name">name for range to be get</param> /// <param name="namedRange">output argument, range assoicated with specified name will be returned</param> /// <returns>true if specified name exists and the instance of range has been returned from spreadsheet, otherwise false</returns> public bool TryGetNamedRange(string name, out NamedRange namedRange) { if (!RGUtility.IsValidName(name)) { namedRange = null; return(false); } else { return(registeredNamedRanges.TryGetValue(name, out namedRange)); } }
internal bool TryGetNamedRangePosition(string name, out RangePosition range) { if (!RGUtility.IsValidName(name)) { range = RangePosition.Empty; return(false); } else { NamedRange namedRange; registeredNamedRanges.TryGetValue(name, out namedRange); range = namedRange.Position; return(true); } }
/// <summary> /// Remove a highlighted range from specified address /// </summary> /// <param name="address">address to remove highlighted range</param> /// <returns>true if range removed successfully</returns> public bool RemoveHighlightRange(string address) { if (RangePosition.IsValidAddress(address)) { return(RemoveHighlightRange(new RangePosition(address))); } else if (RGUtility.IsValidName(address)) { if (registeredNamedRanges.TryGetValue(address, out var refRange)) { return(RemoveHighlightRange(refRange)); } } return(false); }
/// <summary> /// Select speicifed range on spreadsheet /// </summary> /// <param name="address">address or name of specified range to be selected</param> public void SelectRange(string address) { // range address if (RangePosition.IsValidAddress(address)) { SelectRange(new RangePosition(address)); } // named range else if (RGUtility.IsValidName(address)) { NamedRange refRange; if (registeredNamedRanges.TryGetValue(address, out refRange)) { SelectRange(refRange); } } }
/// <summary> /// Crearte and display a highlighted range at specified position on worksheet /// </summary> /// <param name="address">Address or name to locate a range on worksheet</param> /// <returns>Instance of highlight range on worksheet</returns> public HighlightRange AddHighlightRange(string address) { if (RangePosition.IsValidAddress(address)) { return(AddHighlightRange(new RangePosition(address))); } else if (RGUtility.IsValidName(address)) { NamedRange refRange; if (registeredNamedRanges.TryGetValue(address, out refRange)) { return(AddHighlightRange(refRange)); } } return(null); }
/// <summary> /// Check whether or not the specified name is valid name /// </summary> /// <param name="name">Name to be checked</param> /// <returns>True if specified name is valid; otherwise return false</returns> public static bool IsValidName(string name) { return(RGUtility.IsValidName(name)); }