docx icon indicating copy to clipboard operation
docx copied to clipboard

Simple pure Go (golang) library for creating DOCX file

docx

GitHub release (latest SemVer) Go Report Card GoDoc

Introduction

docx is a simple library to creating DOCX file in Go.

Getting Started

Install

Go modules supported

go get github.com/gingfrederik/docx

Import:

import "github.com/gingfrederik/docx"

Usage

Example:

package main

import (
	"github.com/gingfrederik/docx"
)

func main() {
	f := docx.NewFile()
	// add new paragraph
	para := f.AddParagraph()
	// add text
	para.AddText("test")

	para.AddText("test font size").Size(22)
	para.AddText("test color").Color("808080")
	para.AddText("test font size and color").Size(22).Color("121212")

	nextPara := f.AddParagraph()
	nextPara.AddLink("google", `http://google.com`)

	f.Save("./test.docx")
}