Skip to main content

SlideTable

Struct SlideTable 

Source
pub struct SlideTable {
Show 13 fields pub id: u32, pub name: String, pub offset_emu: (i64, i64), pub extent_emu: (i64, i64), pub column_widths_emu: Vec<i64>, pub rows: Vec<TableRow>, pub style_id: Option<String>, pub style_first_row: bool, pub style_first_column: bool, pub style_last_row: bool, pub style_last_column: bool, pub style_band_rows: bool, pub style_band_columns: bool,
}
Expand description

An embedded table (<p:graphicFrame> wrapping <a:tbl>, a:graphicData uri="../drawingml/2006/table") — DrawingML’s own table vocabulary, distinct from word-ooxml::Table’s WordprocessingML w:tbl (a different XML namespace/vocabulary entirely, despite the conceptual overlap — no code is shared between the two, same posture as every other cross-crate “same real-world concept, separate small copy” case in this workspace, e.g. PictureFormat).

Structure (p:graphicFrame/p:xfrm/a:tbl/a:tblGrid/a:tr/a:tc) confirmed against real fixtures: note the frame’s own transform element is <p:xfrm>, not <a:xfrm>, same as SlideChart’s. <a:tableStyleId> (a GUID referencing a table style) is written from style_id when set (see SlideTableStyle), otherwise falls back to the same fixed built-in default this crate’s tableStyles.xml always declares, matching this crate’s existing posture on p:xfrm/theme boilerplate elsewhere.

Fields§

§id: u32

<p:cNvPr id=".."> — same uniqueness rules as AutoShape::id.

§name: String

<p:cNvPr name="..">.

§offset_emu: (i64, i64)

<p:xfrm><a:off x=".." y="..">, in EMUs.

§extent_emu: (i64, i64)

<p:xfrm><a:ext cx=".." cy="..">, in EMUs.

§column_widths_emu: Vec<i64>

<a:tblGrid>’s <a:gridCol w=".."> widths, in EMUs, one per column (column count is derived from this, mirroring word_ooxml::Table.column_widths).

§rows: Vec<TableRow>§style_id: Option<String>

<a:tableStyleId> — references one of Presentation.table_styles by SlideTableStyle::id. None (the default) falls back to this crate’s fixed built-in style, unchanged.

§style_first_row: bool

<a:tblPr firstRow="."> — applies style_id’s first_row part to this table’s actual first row (a header-row emphasis, e.g. bold text/a distinct fill). false (the default, matching CT_TableProperties’s own schema default) omits the attribute. Without this, a referenced SlideTableStyle’s per-part formatting has no visible effect in real PowerPoint at all — these six toggles are what actually turns each style part “on” for a given table; style_id alone only makes the style available. Grounded against a real fixture (firstRow="1" bandRow="1").

§style_first_column: bool

<a:tblPr firstCol=".."> — applies style_id’s first_column part. See SlideTable::style_first_row’s doc comment.

§style_last_row: bool

<a:tblPr lastRow=".."> — applies style_id’s last_row part (a totals-row emphasis). See SlideTable::style_first_row’s doc comment.

§style_last_column: bool

<a:tblPr lastCol=".."> — applies style_id’s last_column part. See SlideTable::style_first_row’s doc comment.

§style_band_rows: bool

<a:tblPr bandRow=".."> — applies style_id’s band1_horizontal/ band2_horizontal parts as alternating row stripes. See SlideTable::style_first_row’s doc comment.

§style_band_columns: bool

<a:tblPr bandCol=".."> — applies style_id’s band1_vertical/ band2_vertical parts as alternating column stripes. See SlideTable::style_first_row’s doc comment.

Implementations§

Source§

impl SlideTable

Source

pub fn new( id: u32, name: impl Into<String>, width_emu: i64, height_emu: i64, ) -> SlideTable

Creates an empty table (no rows/columns) at the given size, positioned at (0, 0), using the fixed built-in table style with none of its parts (first row/column, last row/column, banding) actually applied.

Examples found in repository?
examples/pptx_tables.rs (line 19)
16fn main() -> office_toolkit::Result<()> {
17    let path = output_path("pptx_tables.pptx");
18
19    let plain_table = SlideTable::new(2, "Plain table", 5_000_000, 1_500_000)
20        .with_offset(838_200, 838_200)
21        .with_column_widths(vec![2_500_000, 2_500_000])
22        .with_row(
23            TableRow::new(500_000)
24                .with_cell(cell("Name"))
25                .with_cell(cell("Score")),
26        )
27        .with_row(
28            TableRow::new(500_000)
29                .with_cell(cell("Alice"))
30                .with_cell(cell("92")),
31        )
32        .with_row(
33            TableRow::new(500_000)
34                .with_cell(cell("Bob"))
35                .with_cell(cell("87")),
36        );
37
38    let merged_table = SlideTable::new(2, "Merged cells", 5_000_000, 1_000_000)
39        .with_offset(838_200, 838_200)
40        .with_column_widths(vec![1_667_000, 1_667_000, 1_666_000])
41        .with_row(
42            TableRow::new(500_000)
43                .with_cell(cell("Spanning header").with_horizontal_span(3))
44                .with_cell(TableCell::horizontally_merged())
45                .with_cell(TableCell::horizontally_merged()),
46        )
47        .with_row(
48            TableRow::new(500_000)
49                .with_cell(cell("A"))
50                .with_cell(cell("B"))
51                .with_cell(cell("C")),
52        );
53
54    let styled_table = SlideTable::new(2, "Styled table", 5_000_000, 1_500_000)
55        .with_offset(838_200, 838_200)
56        .with_style_id("{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}")
57        .with_style_first_row(true)
58        .with_style_band_rows(true)
59        .with_column_widths(vec![2_500_000, 2_500_000])
60        .with_row(
61            TableRow::new(500_000)
62                .with_cell(cell("Header A"))
63                .with_cell(cell("Header B")),
64        )
65        .with_row(
66            TableRow::new(500_000)
67                .with_cell(cell("1"))
68                .with_cell(cell("2")),
69        )
70        .with_row(
71            TableRow::new(500_000)
72                .with_cell(cell("3"))
73                .with_cell(cell("4")),
74        );
75
76    let presentation = Presentation::new()
77        .with_table_style(
78            SlideTableStyle::new(
79                "{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}",
80                "Custom Table Style",
81            )
82            .with_first_row(
83                TableStylePart::new()
84                    .with_fill(Fill::Solid(Color::Rgb("2E74B5".to_string())))
85                    .with_bold(true)
86                    .with_text_color(Color::Rgb("FFFFFF".to_string())),
87            )
88            .with_band1_horizontal(
89                TableStylePart::new().with_fill(Fill::Solid(Color::Rgb("F2F2F2".to_string()))),
90            ),
91        )
92        .with_slide(Slide::new().with_shape(Shape::Table(plain_table)))
93        .with_slide(Slide::new().with_shape(Shape::Table(merged_table)))
94        .with_slide(Slide::new().with_shape(Shape::Table(styled_table)));
95
96    presentation.save_to_file(&path)?;
97    println!("Wrote {}", path.display());
98    Ok(())
99}
Source

pub fn with_offset(self, x_emu: i64, y_emu: i64) -> SlideTable

Sets this table’s position.

Examples found in repository?
examples/pptx_tables.rs (line 20)
16fn main() -> office_toolkit::Result<()> {
17    let path = output_path("pptx_tables.pptx");
18
19    let plain_table = SlideTable::new(2, "Plain table", 5_000_000, 1_500_000)
20        .with_offset(838_200, 838_200)
21        .with_column_widths(vec![2_500_000, 2_500_000])
22        .with_row(
23            TableRow::new(500_000)
24                .with_cell(cell("Name"))
25                .with_cell(cell("Score")),
26        )
27        .with_row(
28            TableRow::new(500_000)
29                .with_cell(cell("Alice"))
30                .with_cell(cell("92")),
31        )
32        .with_row(
33            TableRow::new(500_000)
34                .with_cell(cell("Bob"))
35                .with_cell(cell("87")),
36        );
37
38    let merged_table = SlideTable::new(2, "Merged cells", 5_000_000, 1_000_000)
39        .with_offset(838_200, 838_200)
40        .with_column_widths(vec![1_667_000, 1_667_000, 1_666_000])
41        .with_row(
42            TableRow::new(500_000)
43                .with_cell(cell("Spanning header").with_horizontal_span(3))
44                .with_cell(TableCell::horizontally_merged())
45                .with_cell(TableCell::horizontally_merged()),
46        )
47        .with_row(
48            TableRow::new(500_000)
49                .with_cell(cell("A"))
50                .with_cell(cell("B"))
51                .with_cell(cell("C")),
52        );
53
54    let styled_table = SlideTable::new(2, "Styled table", 5_000_000, 1_500_000)
55        .with_offset(838_200, 838_200)
56        .with_style_id("{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}")
57        .with_style_first_row(true)
58        .with_style_band_rows(true)
59        .with_column_widths(vec![2_500_000, 2_500_000])
60        .with_row(
61            TableRow::new(500_000)
62                .with_cell(cell("Header A"))
63                .with_cell(cell("Header B")),
64        )
65        .with_row(
66            TableRow::new(500_000)
67                .with_cell(cell("1"))
68                .with_cell(cell("2")),
69        )
70        .with_row(
71            TableRow::new(500_000)
72                .with_cell(cell("3"))
73                .with_cell(cell("4")),
74        );
75
76    let presentation = Presentation::new()
77        .with_table_style(
78            SlideTableStyle::new(
79                "{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}",
80                "Custom Table Style",
81            )
82            .with_first_row(
83                TableStylePart::new()
84                    .with_fill(Fill::Solid(Color::Rgb("2E74B5".to_string())))
85                    .with_bold(true)
86                    .with_text_color(Color::Rgb("FFFFFF".to_string())),
87            )
88            .with_band1_horizontal(
89                TableStylePart::new().with_fill(Fill::Solid(Color::Rgb("F2F2F2".to_string()))),
90            ),
91        )
92        .with_slide(Slide::new().with_shape(Shape::Table(plain_table)))
93        .with_slide(Slide::new().with_shape(Shape::Table(merged_table)))
94        .with_slide(Slide::new().with_shape(Shape::Table(styled_table)));
95
96    presentation.save_to_file(&path)?;
97    println!("Wrote {}", path.display());
98    Ok(())
99}
Source

pub fn with_style_id(self, style_id: impl Into<String>) -> SlideTable

Uses a custom table style (by id) instead of the fixed built-in one.

Examples found in repository?
examples/pptx_tables.rs (line 56)
16fn main() -> office_toolkit::Result<()> {
17    let path = output_path("pptx_tables.pptx");
18
19    let plain_table = SlideTable::new(2, "Plain table", 5_000_000, 1_500_000)
20        .with_offset(838_200, 838_200)
21        .with_column_widths(vec![2_500_000, 2_500_000])
22        .with_row(
23            TableRow::new(500_000)
24                .with_cell(cell("Name"))
25                .with_cell(cell("Score")),
26        )
27        .with_row(
28            TableRow::new(500_000)
29                .with_cell(cell("Alice"))
30                .with_cell(cell("92")),
31        )
32        .with_row(
33            TableRow::new(500_000)
34                .with_cell(cell("Bob"))
35                .with_cell(cell("87")),
36        );
37
38    let merged_table = SlideTable::new(2, "Merged cells", 5_000_000, 1_000_000)
39        .with_offset(838_200, 838_200)
40        .with_column_widths(vec![1_667_000, 1_667_000, 1_666_000])
41        .with_row(
42            TableRow::new(500_000)
43                .with_cell(cell("Spanning header").with_horizontal_span(3))
44                .with_cell(TableCell::horizontally_merged())
45                .with_cell(TableCell::horizontally_merged()),
46        )
47        .with_row(
48            TableRow::new(500_000)
49                .with_cell(cell("A"))
50                .with_cell(cell("B"))
51                .with_cell(cell("C")),
52        );
53
54    let styled_table = SlideTable::new(2, "Styled table", 5_000_000, 1_500_000)
55        .with_offset(838_200, 838_200)
56        .with_style_id("{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}")
57        .with_style_first_row(true)
58        .with_style_band_rows(true)
59        .with_column_widths(vec![2_500_000, 2_500_000])
60        .with_row(
61            TableRow::new(500_000)
62                .with_cell(cell("Header A"))
63                .with_cell(cell("Header B")),
64        )
65        .with_row(
66            TableRow::new(500_000)
67                .with_cell(cell("1"))
68                .with_cell(cell("2")),
69        )
70        .with_row(
71            TableRow::new(500_000)
72                .with_cell(cell("3"))
73                .with_cell(cell("4")),
74        );
75
76    let presentation = Presentation::new()
77        .with_table_style(
78            SlideTableStyle::new(
79                "{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}",
80                "Custom Table Style",
81            )
82            .with_first_row(
83                TableStylePart::new()
84                    .with_fill(Fill::Solid(Color::Rgb("2E74B5".to_string())))
85                    .with_bold(true)
86                    .with_text_color(Color::Rgb("FFFFFF".to_string())),
87            )
88            .with_band1_horizontal(
89                TableStylePart::new().with_fill(Fill::Solid(Color::Rgb("F2F2F2".to_string()))),
90            ),
91        )
92        .with_slide(Slide::new().with_shape(Shape::Table(plain_table)))
93        .with_slide(Slide::new().with_shape(Shape::Table(merged_table)))
94        .with_slide(Slide::new().with_shape(Shape::Table(styled_table)));
95
96    presentation.save_to_file(&path)?;
97    println!("Wrote {}", path.display());
98    Ok(())
99}
Source

pub fn with_column_widths( self, column_widths_emu: impl Into<Vec<i64>>, ) -> SlideTable

Sets the column widths (and, implicitly, the column count).

Examples found in repository?
examples/pptx_tables.rs (line 21)
16fn main() -> office_toolkit::Result<()> {
17    let path = output_path("pptx_tables.pptx");
18
19    let plain_table = SlideTable::new(2, "Plain table", 5_000_000, 1_500_000)
20        .with_offset(838_200, 838_200)
21        .with_column_widths(vec![2_500_000, 2_500_000])
22        .with_row(
23            TableRow::new(500_000)
24                .with_cell(cell("Name"))
25                .with_cell(cell("Score")),
26        )
27        .with_row(
28            TableRow::new(500_000)
29                .with_cell(cell("Alice"))
30                .with_cell(cell("92")),
31        )
32        .with_row(
33            TableRow::new(500_000)
34                .with_cell(cell("Bob"))
35                .with_cell(cell("87")),
36        );
37
38    let merged_table = SlideTable::new(2, "Merged cells", 5_000_000, 1_000_000)
39        .with_offset(838_200, 838_200)
40        .with_column_widths(vec![1_667_000, 1_667_000, 1_666_000])
41        .with_row(
42            TableRow::new(500_000)
43                .with_cell(cell("Spanning header").with_horizontal_span(3))
44                .with_cell(TableCell::horizontally_merged())
45                .with_cell(TableCell::horizontally_merged()),
46        )
47        .with_row(
48            TableRow::new(500_000)
49                .with_cell(cell("A"))
50                .with_cell(cell("B"))
51                .with_cell(cell("C")),
52        );
53
54    let styled_table = SlideTable::new(2, "Styled table", 5_000_000, 1_500_000)
55        .with_offset(838_200, 838_200)
56        .with_style_id("{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}")
57        .with_style_first_row(true)
58        .with_style_band_rows(true)
59        .with_column_widths(vec![2_500_000, 2_500_000])
60        .with_row(
61            TableRow::new(500_000)
62                .with_cell(cell("Header A"))
63                .with_cell(cell("Header B")),
64        )
65        .with_row(
66            TableRow::new(500_000)
67                .with_cell(cell("1"))
68                .with_cell(cell("2")),
69        )
70        .with_row(
71            TableRow::new(500_000)
72                .with_cell(cell("3"))
73                .with_cell(cell("4")),
74        );
75
76    let presentation = Presentation::new()
77        .with_table_style(
78            SlideTableStyle::new(
79                "{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}",
80                "Custom Table Style",
81            )
82            .with_first_row(
83                TableStylePart::new()
84                    .with_fill(Fill::Solid(Color::Rgb("2E74B5".to_string())))
85                    .with_bold(true)
86                    .with_text_color(Color::Rgb("FFFFFF".to_string())),
87            )
88            .with_band1_horizontal(
89                TableStylePart::new().with_fill(Fill::Solid(Color::Rgb("F2F2F2".to_string()))),
90            ),
91        )
92        .with_slide(Slide::new().with_shape(Shape::Table(plain_table)))
93        .with_slide(Slide::new().with_shape(Shape::Table(merged_table)))
94        .with_slide(Slide::new().with_shape(Shape::Table(styled_table)));
95
96    presentation.save_to_file(&path)?;
97    println!("Wrote {}", path.display());
98    Ok(())
99}
Source

pub fn with_row(self, row: TableRow) -> SlideTable

Appends a row.

Examples found in repository?
examples/pptx_tables.rs (lines 22-26)
16fn main() -> office_toolkit::Result<()> {
17    let path = output_path("pptx_tables.pptx");
18
19    let plain_table = SlideTable::new(2, "Plain table", 5_000_000, 1_500_000)
20        .with_offset(838_200, 838_200)
21        .with_column_widths(vec![2_500_000, 2_500_000])
22        .with_row(
23            TableRow::new(500_000)
24                .with_cell(cell("Name"))
25                .with_cell(cell("Score")),
26        )
27        .with_row(
28            TableRow::new(500_000)
29                .with_cell(cell("Alice"))
30                .with_cell(cell("92")),
31        )
32        .with_row(
33            TableRow::new(500_000)
34                .with_cell(cell("Bob"))
35                .with_cell(cell("87")),
36        );
37
38    let merged_table = SlideTable::new(2, "Merged cells", 5_000_000, 1_000_000)
39        .with_offset(838_200, 838_200)
40        .with_column_widths(vec![1_667_000, 1_667_000, 1_666_000])
41        .with_row(
42            TableRow::new(500_000)
43                .with_cell(cell("Spanning header").with_horizontal_span(3))
44                .with_cell(TableCell::horizontally_merged())
45                .with_cell(TableCell::horizontally_merged()),
46        )
47        .with_row(
48            TableRow::new(500_000)
49                .with_cell(cell("A"))
50                .with_cell(cell("B"))
51                .with_cell(cell("C")),
52        );
53
54    let styled_table = SlideTable::new(2, "Styled table", 5_000_000, 1_500_000)
55        .with_offset(838_200, 838_200)
56        .with_style_id("{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}")
57        .with_style_first_row(true)
58        .with_style_band_rows(true)
59        .with_column_widths(vec![2_500_000, 2_500_000])
60        .with_row(
61            TableRow::new(500_000)
62                .with_cell(cell("Header A"))
63                .with_cell(cell("Header B")),
64        )
65        .with_row(
66            TableRow::new(500_000)
67                .with_cell(cell("1"))
68                .with_cell(cell("2")),
69        )
70        .with_row(
71            TableRow::new(500_000)
72                .with_cell(cell("3"))
73                .with_cell(cell("4")),
74        );
75
76    let presentation = Presentation::new()
77        .with_table_style(
78            SlideTableStyle::new(
79                "{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}",
80                "Custom Table Style",
81            )
82            .with_first_row(
83                TableStylePart::new()
84                    .with_fill(Fill::Solid(Color::Rgb("2E74B5".to_string())))
85                    .with_bold(true)
86                    .with_text_color(Color::Rgb("FFFFFF".to_string())),
87            )
88            .with_band1_horizontal(
89                TableStylePart::new().with_fill(Fill::Solid(Color::Rgb("F2F2F2".to_string()))),
90            ),
91        )
92        .with_slide(Slide::new().with_shape(Shape::Table(plain_table)))
93        .with_slide(Slide::new().with_shape(Shape::Table(merged_table)))
94        .with_slide(Slide::new().with_shape(Shape::Table(styled_table)));
95
96    presentation.save_to_file(&path)?;
97    println!("Wrote {}", path.display());
98    Ok(())
99}
Source

pub fn with_style_first_row(self, apply: bool) -> SlideTable

Applies the referenced style’s first-row part to this table’s actual first row (e.g. a bold header row).

Examples found in repository?
examples/pptx_tables.rs (line 57)
16fn main() -> office_toolkit::Result<()> {
17    let path = output_path("pptx_tables.pptx");
18
19    let plain_table = SlideTable::new(2, "Plain table", 5_000_000, 1_500_000)
20        .with_offset(838_200, 838_200)
21        .with_column_widths(vec![2_500_000, 2_500_000])
22        .with_row(
23            TableRow::new(500_000)
24                .with_cell(cell("Name"))
25                .with_cell(cell("Score")),
26        )
27        .with_row(
28            TableRow::new(500_000)
29                .with_cell(cell("Alice"))
30                .with_cell(cell("92")),
31        )
32        .with_row(
33            TableRow::new(500_000)
34                .with_cell(cell("Bob"))
35                .with_cell(cell("87")),
36        );
37
38    let merged_table = SlideTable::new(2, "Merged cells", 5_000_000, 1_000_000)
39        .with_offset(838_200, 838_200)
40        .with_column_widths(vec![1_667_000, 1_667_000, 1_666_000])
41        .with_row(
42            TableRow::new(500_000)
43                .with_cell(cell("Spanning header").with_horizontal_span(3))
44                .with_cell(TableCell::horizontally_merged())
45                .with_cell(TableCell::horizontally_merged()),
46        )
47        .with_row(
48            TableRow::new(500_000)
49                .with_cell(cell("A"))
50                .with_cell(cell("B"))
51                .with_cell(cell("C")),
52        );
53
54    let styled_table = SlideTable::new(2, "Styled table", 5_000_000, 1_500_000)
55        .with_offset(838_200, 838_200)
56        .with_style_id("{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}")
57        .with_style_first_row(true)
58        .with_style_band_rows(true)
59        .with_column_widths(vec![2_500_000, 2_500_000])
60        .with_row(
61            TableRow::new(500_000)
62                .with_cell(cell("Header A"))
63                .with_cell(cell("Header B")),
64        )
65        .with_row(
66            TableRow::new(500_000)
67                .with_cell(cell("1"))
68                .with_cell(cell("2")),
69        )
70        .with_row(
71            TableRow::new(500_000)
72                .with_cell(cell("3"))
73                .with_cell(cell("4")),
74        );
75
76    let presentation = Presentation::new()
77        .with_table_style(
78            SlideTableStyle::new(
79                "{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}",
80                "Custom Table Style",
81            )
82            .with_first_row(
83                TableStylePart::new()
84                    .with_fill(Fill::Solid(Color::Rgb("2E74B5".to_string())))
85                    .with_bold(true)
86                    .with_text_color(Color::Rgb("FFFFFF".to_string())),
87            )
88            .with_band1_horizontal(
89                TableStylePart::new().with_fill(Fill::Solid(Color::Rgb("F2F2F2".to_string()))),
90            ),
91        )
92        .with_slide(Slide::new().with_shape(Shape::Table(plain_table)))
93        .with_slide(Slide::new().with_shape(Shape::Table(merged_table)))
94        .with_slide(Slide::new().with_shape(Shape::Table(styled_table)));
95
96    presentation.save_to_file(&path)?;
97    println!("Wrote {}", path.display());
98    Ok(())
99}
Source

pub fn with_style_first_column(self, apply: bool) -> SlideTable

Applies the referenced style’s first-column part.

Source

pub fn with_style_last_row(self, apply: bool) -> SlideTable

Applies the referenced style’s last-row part (e.g. a totals row).

Source

pub fn with_style_last_column(self, apply: bool) -> SlideTable

Applies the referenced style’s last-column part.

Source

pub fn with_style_band_rows(self, apply: bool) -> SlideTable

Applies the referenced style’s horizontal-banding parts (alternating row stripes).

Examples found in repository?
examples/pptx_tables.rs (line 58)
16fn main() -> office_toolkit::Result<()> {
17    let path = output_path("pptx_tables.pptx");
18
19    let plain_table = SlideTable::new(2, "Plain table", 5_000_000, 1_500_000)
20        .with_offset(838_200, 838_200)
21        .with_column_widths(vec![2_500_000, 2_500_000])
22        .with_row(
23            TableRow::new(500_000)
24                .with_cell(cell("Name"))
25                .with_cell(cell("Score")),
26        )
27        .with_row(
28            TableRow::new(500_000)
29                .with_cell(cell("Alice"))
30                .with_cell(cell("92")),
31        )
32        .with_row(
33            TableRow::new(500_000)
34                .with_cell(cell("Bob"))
35                .with_cell(cell("87")),
36        );
37
38    let merged_table = SlideTable::new(2, "Merged cells", 5_000_000, 1_000_000)
39        .with_offset(838_200, 838_200)
40        .with_column_widths(vec![1_667_000, 1_667_000, 1_666_000])
41        .with_row(
42            TableRow::new(500_000)
43                .with_cell(cell("Spanning header").with_horizontal_span(3))
44                .with_cell(TableCell::horizontally_merged())
45                .with_cell(TableCell::horizontally_merged()),
46        )
47        .with_row(
48            TableRow::new(500_000)
49                .with_cell(cell("A"))
50                .with_cell(cell("B"))
51                .with_cell(cell("C")),
52        );
53
54    let styled_table = SlideTable::new(2, "Styled table", 5_000_000, 1_500_000)
55        .with_offset(838_200, 838_200)
56        .with_style_id("{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}")
57        .with_style_first_row(true)
58        .with_style_band_rows(true)
59        .with_column_widths(vec![2_500_000, 2_500_000])
60        .with_row(
61            TableRow::new(500_000)
62                .with_cell(cell("Header A"))
63                .with_cell(cell("Header B")),
64        )
65        .with_row(
66            TableRow::new(500_000)
67                .with_cell(cell("1"))
68                .with_cell(cell("2")),
69        )
70        .with_row(
71            TableRow::new(500_000)
72                .with_cell(cell("3"))
73                .with_cell(cell("4")),
74        );
75
76    let presentation = Presentation::new()
77        .with_table_style(
78            SlideTableStyle::new(
79                "{66BB4812-77A1-49B3-BDF9-0CCEB564D7B5}",
80                "Custom Table Style",
81            )
82            .with_first_row(
83                TableStylePart::new()
84                    .with_fill(Fill::Solid(Color::Rgb("2E74B5".to_string())))
85                    .with_bold(true)
86                    .with_text_color(Color::Rgb("FFFFFF".to_string())),
87            )
88            .with_band1_horizontal(
89                TableStylePart::new().with_fill(Fill::Solid(Color::Rgb("F2F2F2".to_string()))),
90            ),
91        )
92        .with_slide(Slide::new().with_shape(Shape::Table(plain_table)))
93        .with_slide(Slide::new().with_shape(Shape::Table(merged_table)))
94        .with_slide(Slide::new().with_shape(Shape::Table(styled_table)));
95
96    presentation.save_to_file(&path)?;
97    println!("Wrote {}", path.display());
98    Ok(())
99}
Source

pub fn with_style_band_columns(self, apply: bool) -> SlideTable

Applies the referenced style’s vertical-banding parts (alternating column stripes).

Trait Implementations§

Source§

impl Clone for SlideTable

Source§

fn clone(&self) -> SlideTable

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 SlideTable

Source§

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

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

impl PartialEq for SlideTable

Source§

fn eq(&self, other: &SlideTable) -> 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 SlideTable

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.