Skip to main content

DrawingAnchor

Struct DrawingAnchor 

Source
pub struct DrawingAnchor {
    pub from: CellAnchorPoint,
    pub to: CellAnchorPoint,
    pub object: DrawingObject,
}
Expand description

One cell-anchored drawing object (<xdr:twoCellAnchor>, CT_TwoCellAnchor).

Only the two-cell anchor is modeled (from/to cell markers, editAs always the schema default "twoCell") — by far the common case real spreadsheet tools generate (CT_OneCellAnchor/ CT_AbsoluteAnchor exist in the schema but are rarely if ever generated, only tolerated on read). A wholly absent anchor kind on read is simply skipped by this crate’s forgiving reader, consistent with the rest of this workspace’s posture.

Fields§

§from: CellAnchorPoint§to: CellAnchorPoint§object: DrawingObject

Implementations§

Source§

impl DrawingAnchor

Source

pub fn new( from: CellAnchorPoint, to: CellAnchorPoint, object: DrawingObject, ) -> DrawingAnchor

Examples found in repository?
examples/xlsx_images_and_charts.rs (lines 28-32)
21fn main() -> office_toolkit::Result<()> {
22    let path = output_path("xlsx_images_and_charts.xlsx");
23    let image_bytes = std::fs::read(image_fixture_path())?;
24
25    let picture = SheetPicture::new(image_bytes, PictureFormat::Png).with_name("Test image");
26    let picture_sheet = Sheet::new("Picture")
27        .with_row(Row::new().with_text("The picture is anchored to cell A1:"))
28        .with_drawing(SheetDrawing::new().with_anchor(DrawingAnchor::new(
29            CellAnchorPoint::new(0, 1),
30            CellAnchorPoint::new(2, 6),
31            DrawingObject::Picture(Box::new(picture)),
32        )));
33
34    let chart = SheetChart::new(sample_chart_space()).with_name("Quarterly revenue");
35    let chart_sheet = Sheet::new("Chart")
36        .with_row(Row::new().with_text("A bar chart is anchored below:"))
37        .with_drawing(SheetDrawing::new().with_anchor(DrawingAnchor::new(
38            CellAnchorPoint::new(0, 1),
39            CellAnchorPoint::new(6, 16),
40            DrawingObject::Chart(Box::new(chart)),
41        )));
42
43    let workbook = Workbook::new()
44        .with_sheet(picture_sheet)
45        .with_sheet(chart_sheet);
46    workbook.save_to_file(&path)?;
47    println!("Wrote {}", path.display());
48    Ok(())
49}

Trait Implementations§

Source§

impl Clone for DrawingAnchor

Source§

fn clone(&self) -> DrawingAnchor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DrawingAnchor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for DrawingAnchor

Source§

fn eq(&self, other: &DrawingAnchor) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DrawingAnchor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.