pub struct SheetChart {
pub chart_space: ChartSpace,
pub name: String,
}Expand description
A chart embedded in a sheet’s drawing (<xdr:graphicFrame> referencing a dedicated
xl/charts/chartN.xml part via <c:chart r:id="..">), anchored by its enclosing
DrawingAnchor. Wraps the whole chart::ChartSpace this crate’s chart dependency already
knows how to read/write in full — no Excel-specific chart modeling needed here, and no embedded
workbook needed either (an Excel chart reads its series directly from this same workbook’s
cells, via each series’ own cell-reference formulas already carried by
chart::NumericDataSource/StringDataSource).
Fields§
§chart_space: ChartSpace§name: StringNon-visual name (<xdr:cNvPr name="..">).
Implementations§
Source§impl SheetChart
impl SheetChart
Sourcepub fn new(chart_space: ChartSpace) -> SheetChart
pub fn new(chart_space: ChartSpace) -> SheetChart
Examples found in repository?
examples/xlsx_images_and_charts.rs (line 34)
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>) -> SheetChart
pub fn with_name(self, name: impl Into<String>) -> SheetChart
Examples found in repository?
examples/xlsx_images_and_charts.rs (line 34)
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 SheetChart
impl Clone for SheetChart
Source§fn clone(&self) -> SheetChart
fn clone(&self) -> SheetChart
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 SheetChart
impl Debug for SheetChart
Source§impl PartialEq for SheetChart
impl PartialEq for SheetChart
impl StructuralPartialEq for SheetChart
Auto Trait Implementations§
impl Freeze for SheetChart
impl RefUnwindSafe for SheetChart
impl Send for SheetChart
impl Sync for SheetChart
impl Unpin for SheetChart
impl UnsafeUnpin for SheetChart
impl UnwindSafe for SheetChart
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