excel

package
v0.0.0-...-96b1c7e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

package main

import (
	"encoding/json"
	"fmt"
	"github.com/10001110/yon-jigen-poketto/excel"
)

// SR
// o -> order
// w -> width
// t -> title
type SR struct {
	EventTime        string  `xlsx:"o:4;w:10;t:时间"`
	SearchContent    string  `xlsx:"o:1;w:20;t:内容"`
	SearchResultsYes string  `xlsx:"o:2;w:20;t:是否有搜索结果"`
	AreaCode         int     `xlsx:"o:3;w:20;t:地区码"`
	ASD              float64 `xlsx:"o:5;w:20;t:asd"`
	Ignore           string  // 这个字段没有xlsx标签,不会写入到excel,
}

func main() {
	var s = make([]SR, 0)

	sr01 := SR{"2021-12-08", "hello", "no", 110110, 12.4, ""}
	sr02 := SR{"2021-12-08", "shutdown -h now", "no", 119119, 3.14, ""}
	sr03 := SR{"2021-12-08", "teacher guo", "yes", 112114, 2.717, "this will be ignored"}
	sr04 := SR{"2021-12-08", "oh oh oh", "no", 911911, 69.411, ""}
	s = append(s, sr01, sr02, sr03, sr04)

	// create excel
	where := excel.Create("/Users/haonan/go/src/xxx/sr1", "search content", SR{}, s)
	println(where)

	// read excel
	slice, _ := excel.Read("/Users/haonan/go/src/xxx/sr1.xlsx", "search content", SR{}, true)
	for _, v := range slice.([]SR) {
		marshal, _ := json.Marshal(v)
		fmt.Println(string(marshal))
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(filename, sheetName string, look, inputDataSet interface{}) string

func Read

func Read(file, sheet string, look interface{}, skipFirstLine bool) (interface{}, error)

Types

type Desc

type Desc struct {
	O         int    `json:"o"`
	W         int    `json:"w"`
	T         string `json:"t"`
	FiledName string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL