Go to file
bokuweb dab371dfc6
Create LICENSE (#30)
2020-01-31 01:48:26 +09:00
.github refactor: rename macros (#25) 2020-01-24 17:57:14 +09:00
.vscode feat: Add table property 2019-11-12 18:02:50 +09:00
docs chore: update docs (#10) 2019-12-14 10:15:36 +09:00
docx-core Rename (#27) 2020-01-24 19:44:43 +09:00
docx-wasm Fix run props (#29) 2020-01-31 01:14:48 +09:00
fixtures Support hidden (#8) 2019-12-14 00:47:47 +09:00
output feat: Support alignment 2019-11-11 13:05:07 +09:00
vrt spec: Add VRT foundation 2019-11-12 13:33:45 +09:00
.gitignore Improve js api (#28) 2020-01-30 23:14:25 +09:00
Cargo.lock Rename (#27) 2020-01-24 19:44:43 +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 Improve js api (#28) 2020-01-30 23:14:25 +09:00
logo.png Add files via upload 2020-01-24 15:21:07 +09:00
makefile refactor: rename macros (#25) 2020-01-24 17:57:14 +09:00

README.md

A .docx file generater with Rust/WebAssembly.


GitHub Actions Status

Installation

Rust

[dependencies]
docx-rs = "0.2.0"

Browser

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");
});

More examples

Features

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