pub struct Hyperlink {
pub range: Dimensions,
pub target: Option<String>,
pub location: Option<String>,
pub displayed_text: Option<String>,
pub tooltip: Option<String>,
}Expand description
A hyperlink declared on an XLSX worksheet.
Hyperlinks are anchored to a cell or cell range and point to one of the link types supported by Excel:
- A web-based URI such as
http://,https://,ftp://,ftps://,mailto:or a customprotocol://domainlink — stored inHyperlink::target. - A local file link using the
file://URI (e.g.file:///C:\Temp\Book1.xlsxorfile:///Book2.xlsx#'Sales Data'!A1:G5) — stored inHyperlink::target. - An internal link to a cell or range in the same workbook (e.g.
'Sheet2'!B5) — stored inHyperlink::location, withHyperlink::targetleft asNone.
A single hyperlink may combine an external target with an internal location, in which case the location acts as a sub-anchor within the target file.
Fields§
§range: DimensionsCell or range the hyperlink is anchored to.
target: Option<String>External link target.
This holds the subset of Excel link types that resolve to an external
resource: web URIs (e.g. https://example.com), email addresses (e.g.
mailto:foo@example.com) and local file links (e.g.
file:///C:\Temp\Book1.xlsx).
It is None for purely internal hyperlinks, where only
Hyperlink::location is set.
location: Option<String>In-file location the hyperlink points to, set only for a subset of link types.
For a purely internal link this is the cell, range or named range it
targets (e.g. 'Sheet2'!B5). For an external file link it holds the
sub-anchor — the part after #, e.g. the Sheet1!A1 in
file:///Book2.xlsx#Sheet1!A1 — while Hyperlink::target holds the
file itself. None when the hyperlink has no in-file location.
displayed_text: Option<String>Optional text displayed in the cell instead of the target.
For example a link to https://www.rust-lang.org/ might be displayed
as Rust Programming Language. None when Excel shows the target
itself.
tooltip: Option<String>Optional tooltip shown when hovering the hyperlink in Excel.
Implementations§
Source§impl Hyperlink
impl Hyperlink
Sourcepub fn contains(&self, row: u32, column: u32) -> bool
pub fn contains(&self, row: u32, column: u32) -> bool
Returns true if this hyperlink’s anchor range contains the cell at
the given zero-based (row, column).
This is a convenience for looking up the hyperlink applied to a
specific cell from the vector returned by
Xlsx::hyperlinks_by_sheet_name():
use calamine::{open_workbook, Error, Xlsx};
fn main() -> Result<(), Error> {
let mut workbook: Xlsx<_> = open_workbook("tests/hyperlinks.xlsx")?;
let hyperlinks = workbook.hyperlinks_by_sheet_name("Links")?;
let link = hyperlinks.iter().find(|h| h.contains(0, 0));
assert!(link.is_some());
Ok(())
}Trait Implementations§
impl Eq for Hyperlink
impl StructuralPartialEq for Hyperlink
Auto Trait Implementations§
impl Freeze for Hyperlink
impl RefUnwindSafe for Hyperlink
impl Send for Hyperlink
impl Sync for Hyperlink
impl Unpin for Hyperlink
impl UnsafeUnpin for Hyperlink
impl UnwindSafe for Hyperlink
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.