pub struct SheetPicture {
pub data: Vec<u8>,
pub format: PictureFormat,
pub name: String,
pub shape_properties: Option<ShapeProperties>,
}Expand description
A picture embedded in a sheet’s drawing (<xdr:pic>, CT_Picture — the spreadsheet-drawing
flavor, distinct from a:CT_Picture), anchored by its enclosing DrawingAnchor.
Reuses drawing::ShapeProperties/drawing::BlipFill for the picture’s own formatting
(fill/line/rotation via spPr), the same DrawingML content model word-ooxml’s own picture
support is being generalized toward — this is genuinely shared content, not a parallel
reimplementation. Raw image bytes are supplied directly (data/format), same “no separate
loader type” posture as word_ooxml::Image.
Not modeled: cropping (a:srcRect), picture-specific effects beyond what ShapeProperties
itself carries.
Fields§
§data: Vec<u8>§format: PictureFormat§name: StringAlt text / non-visual name (<xdr:cNvPr name="..">).
shape_properties: Option<ShapeProperties>Implementations§
Source§impl SheetPicture
impl SheetPicture
Sourcepub fn new(data: impl Into<Vec<u8>>, format: PictureFormat) -> SheetPicture
pub fn new(data: impl Into<Vec<u8>>, format: PictureFormat) -> SheetPicture
Examples found in repository?
examples/xlsx_images_and_charts.rs (line 25)
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}Sourcepub fn with_name(self, name: impl Into<String>) -> SheetPicture
pub fn with_name(self, name: impl Into<String>) -> SheetPicture
Examples found in repository?
examples/xlsx_images_and_charts.rs (line 25)
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}pub fn with_shape_properties(self, properties: ShapeProperties) -> SheetPicture
Trait Implementations§
Source§impl Clone for SheetPicture
impl Clone for SheetPicture
Source§fn clone(&self) -> SheetPicture
fn clone(&self) -> SheetPicture
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SheetPicture
impl Debug for SheetPicture
Source§impl PartialEq for SheetPicture
impl PartialEq for SheetPicture
impl StructuralPartialEq for SheetPicture
Auto Trait Implementations§
impl Freeze for SheetPicture
impl RefUnwindSafe for SheetPicture
impl Send for SheetPicture
impl Sync for SheetPicture
impl Unpin for SheetPicture
impl UnsafeUnpin for SheetPicture
impl UnwindSafe for SheetPicture
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
Mutably borrows from an owned value. Read more