Code Monkey home page Code Monkey logo

goexcel's Introduction

goexcel

excel

type s1 struct {
	Name string `export:"一级姓名|姓名2,3"`
	Age  int32  `export:"年龄2,6"`
	Time string `export:"时间2,9"`
}

type s struct {
	Name string `export:"一级姓名|姓名1,2"`
	Age  int32  `export:"年龄1,5"`
	Time string `export:"时间1,8"`
	List []s1
}

type p struct {
	Name   string `export:"一级姓名|二级姓名|姓名,1"`
	Age    int32  `export:"年龄,4"`
	Time   string `export:"时间,7"`
	List   []s
}
func main() {
	v := &p{
		Name: "天外飞仙",
		Age:  18,
		Time: "我是时间",
		List: []s{
			{
				Name: "大名",
				Age:  19,
				Time: "我是大名时间",
				List: []s1{
					{
						Name: "大名",
						Age:  19,
						Time: "我是大名时间",
					},
				},
			},
			{
				Name: "小名",
				Age:  20,
			},
		},
	}
	v2:=&p{
		Name: "天外飞仙",
		Age:  16,
		Time: "我是开始时间",
		List: []s{
			{
				Name: "小名",
				Age:  20,
				Time: "我是小名时间",
				List: []s1{
					{
						Name: "大名",
						Age:  19,
						Time: "我是大名时间",
					},
					{
						Name: "大名",
						Age:  19,
						Time: "我是大名时间",
					},
				},
			},
			{
				Name: "小名",
				Age:  21,
				Time: "我是小名名时间2",
			},
			{
				Name: "小名",
				Age:  21,
				Time: "我是小名名时间2",
			},
		},
	}
	list := append([]*p(nil), v, v2)
	xlsx, err := goexcel.ListToExcelSheet1(list)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	err = xlsx.SaveAs(time.Now().Format("20060102150405") + ".xlsx")
}
一级姓名 年龄 年龄1 年龄2 时间 时间1 时间2
二级姓名 姓名1 姓名2
姓名
天外飞仙 大名 大名 18 19 19 我是时间 我是大名时间 我是大名时间
小名 20
天外飞仙 小名 大名 16 20 19 我是开始时间 我是小名时间 我是大名时间
大名 19 我是大名时间
小名 21 我是小名名时间2
小名 21 我是小名名时间2
// load from excel
var list []*p
goexcel.ExcelSheet1ToListFromPath("20210814182854.xlsx", &list)

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.