2020-01-24 12:44:43 +02:00
|
|
|
use docx_rs::*;
|
|
|
|
|
2020-01-24 11:50:16 +02:00
|
|
|
pub fn main() -> Result<(), DocxError> {
|
|
|
|
let path = std::path::Path::new("./numbering.docx");
|
|
|
|
let file = std::fs::File::create(&path).unwrap();
|
|
|
|
Docx::new()
|
|
|
|
.add_paragraph(
|
|
|
|
Paragraph::new()
|
|
|
|
.add_run(Run::new().add_text("Hello"))
|
|
|
|
.numbering(NumberingId::new(2), IndentLevel::new(0)),
|
|
|
|
)
|
2020-02-11 17:21:26 +02:00
|
|
|
.add_abstract_numbering(
|
|
|
|
AbstractNumbering::new(2).add_level(
|
2020-01-24 11:50:16 +02:00
|
|
|
Level::new(
|
|
|
|
0,
|
|
|
|
Start::new(1),
|
|
|
|
NumberFormat::new("decimal"),
|
|
|
|
LevelText::new("Section %1."),
|
|
|
|
LevelJc::new("left"),
|
|
|
|
)
|
2020-03-10 04:56:12 +02:00
|
|
|
.indent(
|
|
|
|
Some(1620),
|
|
|
|
Some(SpecialIndentType::Hanging(320)),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
),
|
2020-01-24 11:50:16 +02:00
|
|
|
),
|
|
|
|
)
|
2020-02-11 17:21:26 +02:00
|
|
|
.add_numbering(Numbering::new(2, 2))
|
2020-01-24 11:50:16 +02:00
|
|
|
.build()
|
|
|
|
.pack(file)?;
|
|
|
|
Ok(())
|
|
|
|
}
|