Skip to content

Replace {placeholders} and manage content inside .docx files

License

Notifications You must be signed in to change notification settings

xamgore/docx-template

Repository files navigation

docx-template

Replace {placeholders} and manage content inside .docx files.


Dear {crustacean}, → Dear 🦀,


Example

use docx_template::DocxFile;
use serde::Serialize;
use std::error::Error;

fn main() -> Result<(), Box<Error>> {
  let data = Data { crustacean: "🦀".into() };
  let output = DocxFile::from_path("in.docx")?.into_template(data)?.render()?;
  std::fs::write("output.docx", output)?;
  Ok(())
}

#[derive(Serialize)]
struct Data { crustacean: String }

Features

  • serde (default) — use json! macro & Serialize structs to create templates
  • docx-rust — insert markup defined by @cstkingkey/docx‑rust
  • docx-rs — insert markup defined by @bokuweb/docx‑rs

Ecosystem

name description
@bokuweb/docx‑rs
0.4.17
Apr 26, 2024
  • DOM tree (nice naming, limited navigation)
  • Great for write-only scenarios
  • 🔥 WebAssembly support
  • A lot of examples
  • Compiles too many image codecs
  • Internal references and indexes is your own concern
@cstkingkey/docx‑rust
0.1.8
May 21, 2024
  • DOM tree (close to spec naming, conversion helpers)
  • Minimal dependencies
  • Internal references and indexes is your own concern
@yūdachi/docx
1.1.2
(Apr 27, 2020)
💀 (replaced by docx-rust)
@kaisery/ooxmlsdk
0.1.16
Oct 12, 2024
  • Inspired by .NET Open XML SDK
  • Low-level, generated from specification
  • Early development stage
ooxml
0.2.8
Nov 7, 2023
  • Low-level
  • Only .xslx parsing
office-crypto Allows decrypting password protected MS Office files
ms-offcrypto-writer Encrypting ECMA376/OOXML files with agile encryption

Note

Office Open XML (also informally known as OOXML or Microsoft Open XML (MOX)) is a zipped, XML-based file format developed by Microsoft for representing spreadsheets, charts, presentations and word processing documents. The format was initially standardized by Ecma (as ECMA-376), and by the ISO and IEC (as ISO/IEC 29500) in later versions.

About

Replace {placeholders} and manage content inside .docx files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages