Skip to main content

Table

Struct Table 

Source
pub struct Table {
    pub cols: Vec<Col>,
    pub rows: Vec<Row>,
    pub tbl_look: TableLook,
    pub table_style: Option<TableStyle>,
}
Expand description

表格。

Fields§

§cols: Vec<Col>§rows: Vec<Row>§tbl_look: TableLook

表格样式查找属性(控制 tblLook)。

§table_style: Option<TableStyle>

表格样式引用(<a:tableStyleId>)。

None 时不写出 <a:tableStyleId> 元素。

Implementations§

Source§

impl Table

Source

pub fn write_xml(&self, w: &mut XmlWriter)

写 XML(<a:tbl> 嵌在 <a:graphicData uri="..."> 内)。

§OOXML 元素顺序
<a:tbl>
  <a:tblPr>...</a:tblPr>           ← 必须先写,且不含 `<a:tblGrid>`
    <a:tableStyleId>...</a:tableStyleId>  ← 可选,紧跟 tblPr 属性后
  <a:tblGrid>...</a:tblGrid>       ← 列定义(gridCol 列表)
  <a:tr>...</a:tr>                 ← 行(先 cell 后 close)
    <a:tc>                         ← 单元格
      <a:txBody>...</a:txBody>     ← 文本
      <a:tcPr>                     ← 单元格属性(边距/边框/对齐)
        <a:lnL/>/<a:lnR/>/<a:lnT/>/<a:lnB/>
      </a:tcPr>
    </a:tc>
  </a:tr>
  ...
</a:tbl>
Source

pub fn set_style(&mut self, name: &str) -> bool

设置表格样式(按内置样式名称)。

对标 python-pptx Table.apply_style(style_id)

§参数
  • name:内置样式名称(如 “Medium Style 2 - Accent 1”)。
§返回值
  • 成功设置返回 true
  • 名称不在内置注册表中返回 falsetable_style 保持不变)。
§示例
use ooxml_core::oxml::table::Table;

let mut t = Table::default();
assert!(t.set_style("Medium Style 2 - Accent 1"));
assert_eq!(
    t.table_style.as_ref().unwrap().style_id(),
    "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"
);
assert!(!t.set_style("Unknown Style"));
Source

pub fn set_style_id(&mut self, guid: impl Into<String>)

设置表格样式(按原始 GUID)。

用于设置不在内置注册表中的样式(如自定义 tableStyles.xml 中定义的样式)。

§参数
  • guid:样式 GUID 字符串(如 {5C22544A-7EE6-4342-B048-85BDC9FD1C3A})。
Source

pub fn clear_style(&mut self)

清除表格样式引用。

Trait Implementations§

Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

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 Table

Source§

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

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

impl Default for Table

Source§

fn default() -> Table

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

§

impl UnwindSafe for Table

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<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