Skip to main content

TableStyle

Struct TableStyle 

Source
pub struct TableStyle { /* private fields */ }
Expand description

表格样式引用(<a:tableStyleId>{GUID}</a:tableStyleId>)。

OOXML 中表格样式通过 GUID 引用 tableStyles.xml 中定义的 <a:tblStyle>, 或引用 PowerPoint 内置样式(内置样式的 GUID 是预定义的,无需在包内定义)。

§与 python-pptx 的对应

  • python-pptx Table.apply_style(style_id) ←→ TableStyle::new + Table::set_style
  • python-pptx 默认使用 {5C22544A-7EE6-4342-B048-85BDC9FD1C3A}(Medium Style 2 - Accent 1)。

§内置样式

PowerPoint 内置表格样式的 GUID 是固定的,可通过 TableStyle::from_name 按名称查找。 常见样式包括 “No Style, Table Grid”、“Medium Style 2 - Accent 1” 等。

§示例

use ooxml_core::oxml::table::TableStyle;

// 按名称查找内置样式
let style = TableStyle::from_name("Medium Style 2 - Accent 1").unwrap();
assert_eq!(style.style_id(), "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}");

// 直接用 GUID 构造
let style2 = TableStyle::new("{5940675A-B579-460E-94D1-54222C63F5DA}");
assert_eq!(style2.style_id(), "{5940675A-B579-460E-94D1-54222C63F5DA}");

Implementations§

Source§

impl TableStyle

Source

pub fn new(style_id: impl Into<String>) -> TableStyle

用 GUID 构造表格样式引用。

§参数
  • style_id:样式 GUID 字符串(应包含花括号,如 {5C22544A-...})。
Source

pub fn with_name( style_id: impl Into<String>, style_name: impl Into<String>, ) -> TableStyle

用 GUID + 名称构造表格样式引用。

§参数
  • style_id:样式 GUID 字符串;
  • style_name:人类可读的样式名称。
Source

pub fn from_name(name: &str) -> Option<TableStyle>

按名称查找 PowerPoint 内置表格样式。

§参数
  • name:样式名称(如 “Medium Style 2 - Accent 1”)。
§返回值
  • 找到时返回 Some(TableStyle)
  • 名称不在内置注册表中时返回 None
§内置样式列表

目前注册的内置样式(可扩展):

  • “No Style, Table Grid”
  • “No Style, No Grid”
  • “Medium Style 2 - Accent 1”
  • “Themed Style 1 - Accent 1”
Source

pub fn style_id(&self) -> &str

取样式 GUID。

Source

pub fn style_name(&self) -> Option<&str>

取样式名称(可能为 None)。

Trait Implementations§

Source§

impl Clone for TableStyle

Source§

fn clone(&self) -> TableStyle

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 TableStyle

Source§

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

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

impl Eq for TableStyle

Source§

impl PartialEq for TableStyle

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TableStyle

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V