Go to file
bokuweb aceb32f918
feat: Support doc_id (#120)
2020-08-20 00:53:35 +09:00
.github 0.0.63 (#66) 2020-04-30 13:39:56 +09:00
.vscode feat: Add table property 2019-11-12 18:02:50 +09:00
docs chore(deps): update dependency filesaver.js to v2 (#114) 2020-08-12 18:36:52 +09:00
docx-core feat: Support doc_id (#120) 2020-08-20 00:53:35 +09:00
docx-wasm feat: Support doc_id (#120) 2020-08-20 00:53:35 +09:00
fixtures feat: Support doc_id (#120) 2020-08-20 00:53:35 +09:00
images Support image output (#69) 2020-05-14 12:01:20 +09:00
output Support default section header (#115) 2020-08-13 17:27:45 +09:00
vrt build(deps): bump lodash from 4.17.15 to 4.17.19 in /vrt (#98) 2020-08-01 10:18:30 +09:00
.gitignore Support image output (#69) 2020-05-14 12:01:20 +09:00
Cargo.lock 0.0.90 (#118) 2020-08-14 02:11:20 +09:00
Cargo.toml clean wasm dir 2019-11-07 18:11:32 +09:00
LICENSE Create LICENSE (#30) 2020-01-31 01:48:26 +09:00
README.md Support font and paragraph prop (#81) 2020-06-08 13:41:13 +09:00
logo.png Add files via upload 2020-01-24 15:21:07 +09:00
makefile Support nest comment (#116) 2020-08-14 01:57:59 +09:00
renovate.json chore(deps): add renovate.json (#92) 2020-07-30 12:50:32 +09:00

README.md

A .docx file writer with Rust/WebAssembly.


GitHub Actions Status docx-rs at crates.io

Installation

Rust

[dependencies]
docx-rs = "0.2.0"

Browser/Node.js

yarn add docx-wasm

Example

Rust

use docx_rs::*;

pub fn hello() -> Result<(), DocxError> {
    let path = std::path::Path::new("./hello.docx");
    let file = std::fs::File::create(&path).unwrap();
    Docx::new()
        .add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
        .build()
        .pack(file)?;
    Ok(())
}

Browser

import { saveAs } from "file-saver";

// // Note that a dynamic `import` statement here is required due to webpack/webpack#6615,
import("docx-wasm").then(w => {
  const buf = new w.Docx()
    .addParagraph(
      new w.Paragraph().addRun(new w.Run().addText("Hello world!!"))
    )
    .build();
  saveAs(new Blob([buf]), "hello.docx");
});

Node.js

const w = require("docx-wasm");
const { writeFileSync } = require("fs");

const buf = new w.Docx()
  .addParagraph(new w.Paragraph().addRun(new w.Run().addText("Hello world!!")))
  .build();

writeFileSync("hello.docx", buf);

More examples

Features

  • Paragraph
    • Alignment
    • Indent
    • Numbering
  • Run
    • Bold
    • Size
    • Font
    • Color
    • Highlight
    • Underline
    • vanish
    • Italic
  • Break
  • Header
  • Footer
  • Comment
  • Image
  • Style
  • Table
  • HIstory
  • Table of contents
  • Section

Requirements

  • wasm-pack 0.9.1+