excelutils

package
v0.0.0-...-2b29b9b Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// 千位分隔
	CELL_STYLE_THOUSANDS_SEPARATOR string = `#,##0.00_)`
)
View Source
const (
	DEFAULT_SHEET = "Sheet1"
)

Variables

View Source
var ChartMap = map[ExcelChartType]string{
	CHART_TYPE_LINE:    "折线图",
	CHART_TYPE_PIE:     "饼图",
	CHART_TYPE_RADAR:   "雷达图",
	CHART_TYPE_SCATTER: "散点图",
	CHART_TYPE_COL:     "柱状图",
}

Functions

func AddChartWithSheet

func AddChartWithSheet(key, sheet string, chartType ExcelChartType, f *excelize.File) (*excelize.File, error)

func AddNewSheet

func AddNewSheet(data []jsonutils.JSONObject, keys []string, texts []string, sheet string, f *excelize.File) *excelize.File

func CheckChartType

func CheckChartType(chartType string) bool

func Export

func Export(data []jsonutils.JSONObject, keys []string, texts []string, writer io.Writer) error

func ExportFile

func ExportFile(data []jsonutils.JSONObject, keys []string, texts []string, filename string) error

key:data中对应的key,text:头

func ExportWriter

func ExportWriter(data []jsonutils.JSONObject, keys []string, texts []string, writer io.Writer) *excelize.File

func ReadDataWithRow

func ReadDataWithRow(f *excelize.File, sheet string) (jsonutils.JSONObject, error)

按行读取excel文件,注:第一行为json的key

func SetCellStyleWithColumnKey

func SetCellStyleWithColumnKey(keys []string, sheet, style string, f *excelize.File) (*excelize.File, error)

按列设置单元格格式

Types

type ExcelChartType

type ExcelChartType string
const (
	CHART_TYPE_LINE    ExcelChartType = "line"    // 折线图
	CHART_TYPE_PIE     ExcelChartType = "pie"     // 饼图
	CHART_TYPE_RADAR   ExcelChartType = "radar"   // 雷达图
	CHART_TYPE_SCATTER ExcelChartType = "scatter" // 散点图
	CHART_TYPE_COL     ExcelChartType = "col"     // 柱状图
)

type SExcelChartFormat

type SExcelChartFormat struct {
	XScale          float64 `json:"x_scale"`
	YScale          float64 `json:"y_scale"`
	XOffset         float64 `json:"x_offset"`
	YOffset         float64 `json:"y_offset"`
	PrintObj        bool    `json:"print_obj"`
	LockAspectRatio bool    `json:"lock_aspect_ratio"`
	Locked          bool    `json:"locked"`
}

type SExcelChartParams

type SExcelChartParams struct {
	Type   ExcelChartType
	Series []SExcelChartSeries
	Title  SExcelChartTitle
	Format SExcelChartFormat
}

type SExcelChartSeries

type SExcelChartSeries struct {
	Name       string
	Categories string
	Values     string
}

type SExcelChartTitle

type SExcelChartTitle struct {
	Name string
}

Jump to

Keyboard shortcuts

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