Go to file
bokuweb 06a5341348
Improve tr props (#161)
* feat: Read gridAfter

* fix: snaps

* fix: insta
2020-10-09 14:11:46 +09:00
.github Improve level override (#155) 2020-10-05 22:46:18 +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 Improve tr props (#161) 2020-10-09 14:11:46 +09:00
docx-wasm Improve tr props (#161) 2020-10-09 14:11:46 +09:00
fixtures Improve tr props (#161) 2020-10-09 14:11:46 +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 chore(deps): update dependency libreoffice-convert to v1.3.0 (#144) 2020-10-08 09:34:54 +09:00
.gitignore Support image output (#69) 2020-05-14 12:01:20 +09:00
Cargo.lock Improve tr props (#161) 2020-10-09 14:11:46 +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+