pub struct SlideTableStyle {
pub id: String,
pub name: String,
pub whole_table: Option<TableStylePart>,
pub band1_horizontal: Option<TableStylePart>,
pub band2_horizontal: Option<TableStylePart>,
pub band1_vertical: Option<TableStylePart>,
pub band2_vertical: Option<TableStylePart>,
pub first_row: Option<TableStylePart>,
pub last_row: Option<TableStylePart>,
pub first_column: Option<TableStylePart>,
pub last_column: Option<TableStylePart>,
}Expand description
A custom table style (<a:tblStyle styleId="." styleName=".">, CT_TableStyle). Package-wide
(Presentation::table_styles), referenced by id from SlideTable::style_id.
Grounded against a real fixture (ppt/tableStyles.xml, the built-in “Medium Style 2 - Accent 1”
style). Real CT_TableStyle has 12 optional “table part” children
(wholeTbl/band1H/band2H/band1V/band2V/firstRow/lastRow/
firstCol/lastCol/neCell/nwCell/seCell/swCell); this crate models the 9
commonly-authored ones (everything but the four single- corner-cell variants, a real-world
rarity). Within each part (CT_TablePartStyle), only fill + bold/italic + text color are
modeled (see TableStylePart) — no per-side border customization (CT_TableCellBorderStyle)
and no fontRef index, both schema- optional. A deliberate scope reduction, not a
fixture-exhaustive mirror of every real PowerPoint table style’s structure.
Fields§
§id: StringstyleId (ST_Guid) — referenced from SlideTable::style_id.
name: StringstyleName.
whole_table: Option<TableStylePart><a:wholeTbl> — the base style every other part layers on top of.
band1_horizontal: Option<TableStylePart><a:band1H> — odd row banding.
band2_horizontal: Option<TableStylePart><a:band2H> — even row banding.
band1_vertical: Option<TableStylePart><a:band1V> — odd column banding.
band2_vertical: Option<TableStylePart><a:band2V> — even column banding.
first_row: Option<TableStylePart><a:firstRow> — header row.
last_row: Option<TableStylePart><a:lastRow> — total/footer row.
first_column: Option<TableStylePart><a:firstCol>.
last_column: Option<TableStylePart><a:lastCol>.
Implementations§
Source§impl SlideTableStyle
impl SlideTableStyle
Sourcepub fn new(id: impl Into<String>, name: impl Into<String>) -> SlideTableStyle
pub fn new(id: impl Into<String>, name: impl Into<String>) -> SlideTableStyle
Creates a table style with the given id/name and no parts set yet (an empty <a:tblStyle> —
schema-valid, though visually a no-op until at least one part is set).
Examples found in repository?
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}pub fn with_whole_table(self, part: TableStylePart) -> SlideTableStyle
Sourcepub fn with_band1_horizontal(self, part: TableStylePart) -> SlideTableStyle
pub fn with_band1_horizontal(self, part: TableStylePart) -> SlideTableStyle
Examples found in repository?
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}pub fn with_band2_horizontal(self, part: TableStylePart) -> SlideTableStyle
pub fn with_band1_vertical(self, part: TableStylePart) -> SlideTableStyle
pub fn with_band2_vertical(self, part: TableStylePart) -> SlideTableStyle
Sourcepub fn with_first_row(self, part: TableStylePart) -> SlideTableStyle
pub fn with_first_row(self, part: TableStylePart) -> SlideTableStyle
Examples found in repository?
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}pub fn with_last_row(self, part: TableStylePart) -> SlideTableStyle
pub fn with_first_column(self, part: TableStylePart) -> SlideTableStyle
pub fn with_last_column(self, part: TableStylePart) -> SlideTableStyle
Trait Implementations§
Source§impl Clone for SlideTableStyle
impl Clone for SlideTableStyle
Source§fn clone(&self) -> SlideTableStyle
fn clone(&self) -> SlideTableStyle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more