bokuweb / docx-rs

:memo: A .docx file writer with Rust/WebAssembly.
https://bokuweb.github.io/docx-rs/
MIT License
323 stars 56 forks source link

Update table_width.rs #722

Closed hackers267 closed 2 days ago

hackers267 commented 1 month ago

fix the error when build the xml, the width_type is fixed, not pick from the TableWith

What does this change?

Change the fixed WidthType::Dxa to the self.width_type, so let the defined width is useful

References

Screenshots

What can I check for bug fixes?

Use the code to genrerate a docx:

use docx_rs::*;

pub fn main() -> Result<(), DocxError> {
    let path = std::path::Path::new("./table.docx");
    let file = std::fs::File::create(path).unwrap();

    let table = Table::new(vec![TableRow::new(vec![
        TableCell::new().add_paragraph(Paragraph::new())
    ])]).width(5000, WidthType::Pct);
    Docx::new().add_table(table).build().pack(file)?;
    Ok(())
}

then to unzip the table.docx, and check the tblW property's type is pct.

hackers267 commented 2 days ago

What's the reason that can't be merged?

bokuweb commented 2 days ago

sorry, i'm busy.i'll check.

bokuweb commented 2 days ago

LGTM thanks for your contribution