mirror of
https://github.com/ZeroHawkeye/wordZero.git
synced 2025-09-26 20:01:17 +08:00
Page:
en Example Projects
Pages
01 快速开始
02 基础功能
03 样式系统
04 文本格式化
05 表格操作
06 页面设置
07 图片操作
08 高级功能
09 最佳实践
10 API参考
11 示例项目
12 模板功能
13 性能基准测试
14 功能特性详览
15 项目结构详解
16 Markdown双向转换
Home
en API Reference
en Advanced Features
en Basic Features
en Best Practices
en Example Projects
en Feature Overview
en Home
en Image Operations
en Markdown Conversion
en Page Settings
en Performance Benchmarks
en Project Structure
en Quick Start
en Style System
en Table Operations
en Template Features
en Text Formatting
Clone
1
en Example Projects
zero edited this page 2025-06-05 09:38:49 +08:00
Example Projects
This document showcases complete example projects demonstrating practical usage of WordZero in real-world scenarios.
📁 Project Structure Overview
All example projects are located in the examples/
directory:
examples/
├── basic/ # Basic document creation
├── advanced_features/ # Advanced WordZero features
├── table/ # Table manipulation examples
├── style_demo/ # Style system demonstration
├── formatting/ # Text formatting examples
├── template_demo/ # Template system usage
├── markdown_demo/ # Markdown conversion
└── page_settings/ # Page configuration examples
🚀 Getting Started Examples
1. Basic Document Creation
Location: examples/basic/
This example demonstrates the most fundamental WordZero operations:
package main
import (
"fmt"
"log"
"github.com/ZeroHawkeye/wordZero/pkg/document"
"github.com/ZeroHawkeye/wordZero/pkg/style"
)
func main() {
fmt.Println("Creating basic Word document...")
// Create new document
doc := document.New()
// Add title
title := doc.AddParagraph("My First WordZero Document")
title.SetStyle(style.StyleTitle)
// Add subtitle
subtitle := doc.AddParagraph("Learning WordZero with Go")
subtitle.SetStyle(style.StyleSubtitle)
// Add content
content := doc.AddParagraph("This document was created using WordZero, a powerful Go library for Word document manipulation.")
content.SetStyle(style.StyleNormal)
// Save document
if err := doc.Save("examples/output/basic_document.docx"); err != nil {
log.Fatalf("Failed to save document: %v", err)
}
fmt.Println("Document created successfully: examples/output/basic_document.docx")
}
What you'll learn:
- Document creation
- Adding paragraphs
- Applying basic styles
- Saving documents
🚀 Running the Examples
Prerequisites
- Go 1.19 or higher installed
- WordZero library installed:
go get github.com/ZeroHawkeye/wordZero
Running Individual Examples
# Navigate to the project root
cd wordZero
# Run basic example
go run examples/basic/main.go
# Run advanced features example
go run examples/advanced_features/main.go
Output Location
All examples save their output to the examples/output/
directory.
These examples provide a comprehensive foundation for using WordZero in your projects.