Excel binding to struct written in Go.(Only supports Go1.18+)

exl

Excel binding to struct written in Go.(Only supports Go1.18+)

CircleCI GitHub go.mod Go version codecov Go Report Card GoDoc Mentioned in Awesome Go

usage

Read Excel

package main

import (
	"fmt"
	"github.com/go-the-way/exl"
)

type ReadExcelModel struct {
	ID   int    `excel:"ID"`
	Name string `excel:"Name"`
}

func (*ReadExcelModel) ReadMetadata() *exl.ReadMetadata {
	return &exl.ReadMetadata{DataStartRowIndex: 1}
}

func main() {
	if models, err := exl.Read("/to/path.xlsx", new(ReadExcelModel)); err != nil {
		fmt.Println("read excel err:" + err.Error())
	} else {
		fmt.Printf("read excel num: %d\n", len(models))
	}
}

Write Excel

package main

import (
	"fmt"
	"github.com/go-the-way/exl"
)

type WriteExcelModel struct {
	ID   int    `excel:"ID"`
	Name string `excel:"Name"`
}

func (*WriteExcelModel) WriteMetadata() *exl.WriteMetadata {
	return &exl.WriteMetadata{}
}

func main() {
	if err := exl.Write("/to/path.xlsx", []*WriteExcelModel{{100, "apple"}, {200, "pear"}}); err != nil {
		fmt.Println("write excel err:" + err.Error())
	} else {
		fmt.Println("write excel done")
	}
}

Methods

  • exl.Read(reader io.Reader, bind T, filterFunc ...func(t T) (add bool)) error
  • exl.ReadFile(file string, bind T, filterFunc ...func(t T) (add bool)) error
  • exl.ReadBinary(bytes []byte, bind T, filterFunc ...func(t T) (add bool)) error
  • exl.Write(file string, ts []T) error
  • exl.ReadExcel(file string, sheetIndex int, walk func(index int, rows *xlsx.Row)) error
  • exl.WriteExcel(file string, data [][]string) error
Owner
go-the-way
Another go the way!
go-the-way
Similar Resources

GoVector is a vector clock logging library written in Go.

GoVector is a vector clock logging library written in Go.

GoVector is a vector clock logging library written in Go. The vector clock algorithm is used to order events in distributed systems in the absence of a centralized clock. GoVector implements the vector clock algorithm and provides feature-rich logging and encoding infrastructure.

Nov 28, 2022

ChangeTower is intended to help you watch changes in webpages and get notified of any changes written in Go

ChangeTower is intended to help you watch changes in webpages and get notified of any changes written in Go

Nov 17, 2022

Simple log parser written in Golang

Simple log parser written in Golang

Oct 31, 2021

Port information web scraper written in Go.

Whatport is an open source tool that scrapes port information from SpeedGuide's Port Database Usage whatport [port(s)] (Seperate ports with a space)

Aug 18, 2022

An open source Pusher server implementation compatible with Pusher client libraries written in GO

Try browsing the code on Sourcegraph! IPÊ An open source Pusher server implementation compatible with Pusher client libraries written in Go. Why I wro

Jan 3, 2023

A reusable logger module for basic logging, written in Go

A reusable logger module for basic logging, written in Go

logger A reusable logger module for basic logging, written in Go. Usage Client p

Jan 8, 2022

Logger - Simple logger without written with std pkg

Go-Logger Simple usage is: package main

Jan 2, 2022

Stream logs through websockets, written in Go

Stream logs through websockets, written in Go

Jan 8, 2022

A simple digital clock written in go to show time in hh : mm : ss format in console

Go console clock a simple digital clock written in go to show time in "hh : mm :

Feb 3, 2022
Export git log to excel

说明 功能 将git日志导出成excel 使用方法 自己将程序放到bin目录或者复制到程序执行的目录 运行gitlog.exe 参数 -h,显示帮助 -l,导出日志数量,默认50 -m,导出包含merge,默认false -o,输出文件,默认comment.xlsx -v,显示详细输出,,默认fal

Nov 26, 2021
a golang log lib supports level and multi handlers

go-log a golang log lib supports level and multi handlers Use import "github.com/siddontang/go-log/log" //log with different level log.Info("hello wo

Dec 29, 2022
An golang log lib, supports tracking and level, wrap by standard log lib

Logex An golang log lib, supports tracing and level, wrap by standard log lib How To Get shell go get gopkg.in/logex.v1 source code import "gopkg.in/

Nov 27, 2022
dateparse time by struct tag

dateparse_tag dateparse time by struct tag intro&简介 WithTagName() // 自定义你想要使用的tag名称,默认为dateFormat WithDefaultTagValue() // 定义这个tag的默认值,默认为 default Wit

Jan 13, 2022
Goal is to generate logger and tracer wraps around a certain struct
Goal is to generate logger and tracer wraps around a certain struct

Goal is to generate logger and tracer wraps around a certain struct

Feb 13, 2022
The Simplest and worst logging library ever written

gologger A Simple Easy to use go logger library. Displays Colored log into console in any unix or windows platform. You can even store your logs in fi

Sep 26, 2022
LogVoyage - logging SaaS written in GoLang
LogVoyage - logging SaaS written in GoLang

No longer maintained, sorry. Completely rewritten v2 is going to be released soon. Please follow http://github.com/logvoyage LogVoyage - fast and simp

Sep 26, 2022
A Statsd implementation written in GO lang

statsgod Statsgod is a metric aggregation service inspired by the statsd project. Written in Golang, it increases performance and can be deployed with

Oct 1, 2022
A system and resource monitoring tool written in Golang!
A system and resource monitoring tool written in Golang!

Grofer A clean and modern system and resource monitor written purely in golang using termui and gopsutil! Currently compatible with Linux only. Curren

Jan 8, 2023
Logstash like, written in golang

gogstash Logstash like, written in golang Download gogstash from github check latest version Use docker image tsaikd/gogstash curl 'https://github.com

Dec 18, 2022