Git Product home page Git Product logo

go-office's Introduction

go-office

golang的开源办公套件生成器(非编辑器),支持列表如下:

  • Word(段落:o:、表格:o:、页头页脚:o:、基础样式:o:、公式:x:、图表:x:)
  • Excel(基本数据设置:o:、样式:x:、公式:x:、图表:x:)
  • PowerPoint(:x:)

安装

go get -u github.com/Luna-CY/go-office

使用

可以在example目录下查看更多示例

import (
    "github.com/Luna-CY/go-office/docx"
    "github.com/Luna-CY/go-office/docx/paragraph"
)

// 创建一个新的文档
doc := docx.New()

// 设置文档属性
doc.GetSection().GetPageSize().SetWidth(10000).SetHeight(200000)

// 设置默认段落属性
doc.GetProperties().GetDefaultParagraphProperties().GetSpacing().SetSpace(360)

// 添加一个段落
p1 := doc.AddParagraph()

// 设置段落属性
p1.GetProperties().SetHorizontalAlignment(paragraph.HorizontalAlignmentCenter)

// 添加一个文本段
r1 := p1.AddRun()

// 设置文本段属性
r1.GetProperties().GetBackground().SetBackgroundColor("FF0000")

// 在文本段内添加文本
r1.AddText("hello")
r1.AddText(" ")
r1.AddText("word")

// 保存文档
doc.Save("example.docx")

go-office's People

Contributors

luna-cy avatar gztester avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.