godocx

package module
v0.0.7-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 5 Imported by: 3

README

Godocx

Godocx logo

Godocx is a Golang library for creating and modifying DOCX (Microsoft Word) documents.

Usage

Here's a simple example of how you can use Godocx to create and modify DOCX documents:

package main

import (
	"log"

	"github.com/gomutex/godocx"
)

func main() {
	// Open an existing DOCX document
	docx, err := godocx.OpenDocument("./testdata/test.docx")
	if err != nil {
		log.Fatal(err)
	}

	// Add a new paragraph to the document
	_ = docx.AddParagraph("Hello World")
	p := docx.AddEmptyParagraph()
	_ = p.AddText("Add Paragraph and get `Run` instance")

	// Add Heading
	docx.AddHeading("Example Heading", 1) // Heading text and level

	// Save the modified document to a new file
	err = docx.SaveTo("./test_modified.docx")
	if err != nil {
		log.Fatal(err)
	}
}

Examples

Explore additional examples and use cases over at GitHub repository dedicated to showcasing the capabilities of Golang Docx: https://github.com/gomutex/godocx-examples

Inspiration

This GoDocx Library draws inspiration from two renowned libraries in the programming world - python-docx and docx-rs (Rust).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDocument

func NewDocument() (*oxml.RootDoc, error)

NewDocument creates a new document from the default template.

func OpenDocument

func OpenDocument(fileName string) (*oxml.RootDoc, error)

OpenDocument opens a document from the given file name.

Types

This section is empty.

Directories

Path Synopsis
Package constants provides constant values related to OpenXML namespaces, relationships, and other attributes.
Package constants provides constant values related to OpenXML namespaces, relationships, and other attributes.
Package opc provides functionality related to Open Packaging Conventions (OPC).
Package opc provides functionality related to Open Packaging Conventions (OPC).
Package oxml provides utilities for working with Office Open XML (OOXML) documents, including functions related to encoding and decoding XML elements.
Package oxml provides utilities for working with Office Open XML (OOXML) documents, including functions related to encoding and decoding XML elements.
elements
Package elements provides internal structures and functions for working with low-level document elements in GoDocx.
Package elements provides internal structures and functions for working with low-level document elements in GoDocx.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL