-
Notifications
You must be signed in to change notification settings - Fork 53
en API Reference
zero edited this page Jun 5, 2025
·
1 revision
This document provides a complete reference for all public APIs in the WordZero library.
WordZero consists of three main packages:
-
github.com/ZeroHawkeye/wordZero/pkg/document- Core document manipulation -
github.com/ZeroHawkeye/wordZero/pkg/style- Style definitions and management -
github.com/ZeroHawkeye/wordZero/pkg/markdown- Markdown conversion utilities
Creates a new empty Word document.
doc := document.New()Saves the document to the specified file path.
err := doc.Save("document.docx")
if err != nil {
log.Printf("Save failed: %v", err)
}Adds a new paragraph with the specified text to the document.
para := doc.AddParagraph("Hello, WordZero!")Creates a new table with the specified number of rows and columns.
table := doc.AddTable(3, 4) // 3 rows, 4 columnsAdds a table of contents to the document based on heading styles.
err := doc.AddTableOfContents()
if err != nil {
log.Printf("Failed to add TOC: %v", err)
}Applies a predefined style to the paragraph.
err := para.SetStyle(style.StyleHeading1)Adds formatted text to the paragraph.
para.AddFormattedText("Bold text", &document.TextFormat{
Bold: true,
})type TextFormat struct {
FontName string // Font family name
FontSize int // Font size in points
Bold bool // Bold formatting
Italic bool // Italic formatting
Underline bool // Underline formatting
FontColor string // Hex color code (without #)
}Sets the text content of a specific cell.
err := table.SetCellText(0, 0, "Header 1")Gets the text content of a specific cell.
text, err := table.GetCellText(0, 0)const (
StyleNormal StyleType = "Normal"
StyleTitle StyleType = "Title"
StyleSubtitle StyleType = "Subtitle"
StyleHeading1 StyleType = "Heading1"
StyleHeading2 StyleType = "Heading2"
StyleHeading3 StyleType = "Heading3"
StyleQuote StyleType = "Quote"
StyleCodeBlock StyleType = "CodeBlock"
)This API reference provides comprehensive coverage of WordZero's functionality.