model

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type A16CreationId

type A16CreationId struct {
	XMLName  xml.Name `xml:"a16:creationId"`
	XmlnsA16 string   `xml:"xmlns:a16,attr"`
	Id       string   `xml:"id,attr"`
}

type AExt

type AExt struct {
	XMLName       xml.Name       `xml:"a:ext"`
	Uri           string         `xml:"uri,attr"`
	A16CreationId *A16CreationId `xml:"a16:creationId"`
}

type AExtLst

type AExtLst struct {
	XMLName xml.Name `xml:"a:extLst"`
	AExt    *AExt    `xml:"a:ext"`
}

type Alignment

type Alignment struct {
	Horizontal string `xml:"horizontal,attr"` // 水平对齐
	Vertical   string `xml:"vertical,attr"`   // 垂直对齐
}

对齐方式

type AvLst

type AvLst struct {
	XMLName xml.Name `xml:"a:avLst"`
}

AvLst 表示 <avLst> 元素

type Blip

type Blip struct {
	XMLName xml.Name `xml:"a:blip"`
	XmlnsR  string   `xml:"xmlns:r,attr"`
	Embed   string   `xml:"r:embed,attr"`
}

Blip 表示 <blip> 元素

type BlipFill

type BlipFill struct {
	XMLName xml.Name `xml:"xdr:blipFill"`
	Blip    *Blip    `xml:"a:blip"`
	Stretch *Stretch `xml:"a:stretch"`
}

BlipFill 表示 <blipFill> 元素

type Border

type Border struct {
	Left   *Side `xml:"left"`   // 左边框
	Right  *Side `xml:"right"`  // 右边框
	Top    *Side `xml:"top"`    // 上边框
	Bottom *Side `xml:"bottom"` // 下边框
}

单个边框

type Borders

type Borders struct {
	Count  int       `xml:"count,attr"`
	Border []*Border `xml:"border"`
}

边框列表

type CNvPicPr

type CNvPicPr struct {
	XMLName  xml.Name  `xml:"xdr:cnvPicPr"`
	PicLocks *PicLocks `xml:"a:picLocks"`
}

CNvPicPr 表示 <cNvPicPr> 元素

type CNvPr

type CNvPr struct {
	XMLName xml.Name `xml:"xdr:cnvPr"`
	ID      string   `xml:"id,attr"`
	Name    string   `xml:"name,attr"`
	Desc    string   `xml:"descr,attr"`
	AExtLst *AExtLst `xml:"a:extLst"`
}

CNvPr 表示 <cNvPr> 元素

type CalcPr

type CalcPr struct {
	XMLName xml.Name `xml:"calcPr"`
	CalcId  int      `xml:"calcId,attr"`
}

type Cell

type Cell struct {
	XMLName      xml.Name      `xml:"c"`
	Ref          string        `xml:"r,attr"`
	Type         string        `xml:"t,attr,omitempty"`
	Style        string        `xml:"s,attr,omitempty"`
	Value        string        `xml:"v,omitempty"`
	InlineString *InlineString `xml:"is"`
}

type CellStyle

type CellStyle struct {
	Name      string `xml:"name,attr"`
	XfID      string `xml:"xfId,attr"`
	BuiltinId string `xml:"builtinId,attr"`
}

type CellStyleXfs

type CellStyleXfs struct {
	Count int       `xml:"count,attr"`
	Xf    []*CellXf `xml:"xf"`
}

type CellStyles

type CellStyles struct {
	Count     int          `xml:"count,attr"`
	CellStyle []*CellStyle `xml:"cellStyle"`
}

type CellXf

type CellXf struct {
	NumFmtID    int        `xml:"numFmtId,attr"`
	FontID      int        `xml:"fontId,attr"`
	FillID      int        `xml:"fillId,attr"`
	BorderID    int        `xml:"borderId,attr"`
	XfID        int        `xml:"xfId,attr"`
	ApplyFont   bool       `xml:"applyFont,attr"`
	ApplyFill   bool       `xml:"applyFill,attr"`
	ApplyBorder bool       `xml:"applyBorder,attr"`
	Alignment   *Alignment `xml:"alignment"`
}

单个单元格样式

type CellXfs

type CellXfs struct {
	Count int       `xml:"count,attr"`
	Xf    []*CellXf `xml:"xf"`
}

单元格样式列表

type Charset added in v1.2.3

type Charset struct {
	XMLName xml.Name `xml:"charset"`
	Val     string   `xml:"val,attr"`
}

type ClientData

type ClientData struct {
	XMLName xml.Name `xml:"xdr:clientData"`
}

ClientData 表示 <clientData> 元素

type Col

type Col struct {
	Index int
	Cell  string
	Value string
}

type Color

type Color struct {
	RGB   string `xml:"rgb,attr,omitempty"` // 颜色值 (ARGB 格式)
	Theme string `xml:"theme,attr,omitempty"`
}

字体颜色

type ContentType

type ContentType struct {
	XMLName  xml.Name    `xml:"Types"`
	Xmlns    string      `xml:"xmlns,attr"`
	Default  []*Default  `xml:"Default"`
	Override []*Override `xml:"Override"`
}

type Default

type Default struct {
	XMLName     xml.Name `xml:"Default"`
	Extension   string   `xml:"Extension,attr"`
	ContentType string   `xml:"ContentType,attr"`
}

type DefinedName

type DefinedName struct {
	XMLName      xml.Name `xml:"definedName"`
	Name         string   `xml:"name,attr"`
	LocalSheetId int      `xml:"localSheetId,attr"`
}

type DefinedNames

type DefinedNames struct {
	XMLName     xml.Name      `xml:"definedNames"`
	DefinedName []DefinedName `xml:"definedName"`
}

type Dimension

type Dimension struct {
	XMLName xml.Name `xml:"dimension"`
	Ref     string   `xml:"r,attr"`
}

type Drawing

type Drawing struct {
	XMLName        xml.Name         `xml:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing wsDr"`
	Xmlns          string           `xml:"xmlns:xdr,attr"`
	XmlnsA         string           `xml:"xmlns:a,attr"`
	TwoCellAnchors []*TwoCellAnchor `xml:"xdr:twoCellAnchor"`
}

type DxFs

type DxFs struct {
	XMLName xml.Name `xml:"dxfs"`
	Count   int      `xml:"count,attr"`
}

type ExcelWriter

type ExcelWriter struct {
	File                   *os.File
	Writer                 *zip.Writer
	WorkSheets             []*Worksheet
	Relationships          *Relationships
	ContentTypes           *ContentType
	SharedStrings          *SharedString
	SST                    *SST
	StyleSheet             *StyleSheet
	StyleSheetMap          map[*Style]bool
	DrawingMap             map[int]*Drawing
	DrawingRelationshipMap map[int]*Relationships
	SheetRelationshipMap   map[int]*Relationships
	AllImages              map[string]int
}

func (*ExcelWriter) AddFile

func (e *ExcelWriter) AddFile(filename string, content []byte) error

AddFile

@Description: add file to zip
@receiver e
@param filename
@param content
@return error

func (*ExcelWriter) AddSharedString

func (e *ExcelWriter) AddSharedString(str string) int

AddSharedString

@Description: add shared string
@receiver e
@param str
@return int

func (*ExcelWriter) Close

func (e *ExcelWriter) Close() error

func (*ExcelWriter) CreateContentType

func (e *ExcelWriter) CreateContentType()

CreateContentType

@Description: create excel content type
@receiver e

func (*ExcelWriter) CreateDrawing

func (e *ExcelWriter) CreateDrawing()

CreateDrawing

@Description: create drawing
@receiver e

func (*ExcelWriter) CreateSharedString

func (e *ExcelWriter) CreateSharedString()

CreateSharedString

@Description: create shared string file
@receiver e

func (*ExcelWriter) CreateWorksheet

func (e *ExcelWriter) CreateWorksheet() *Worksheet

func (*ExcelWriter) CreateWorksheetRelationship

func (e *ExcelWriter) CreateWorksheetRelationship()

CreateWorksheetRelationship

@Description: create relationship file
@receiver e

func (*ExcelWriter) GetAppSheets

func (e *ExcelWriter) GetAppSheets() string

func (*ExcelWriter) GetBorderId

func (e *ExcelWriter) GetBorderId(style *Style) int

func (*ExcelWriter) GetCellXfId

func (e *ExcelWriter) GetCellXfId(style *Style) int

func (*ExcelWriter) GetExcelFileXml

func (e *ExcelWriter) GetExcelFileXml() (map[string]string, error)

GetExcelFileXml

@Description: Get xml file content
@receiver e
@return map[string]string
@return error

func (*ExcelWriter) GetFillId

func (e *ExcelWriter) GetFillId(style *Style) int

func (*ExcelWriter) GetFontId

func (e *ExcelWriter) GetFontId(style *Style) int

func (*ExcelWriter) GetSharedStringIndex

func (e *ExcelWriter) GetSharedStringIndex(str string) int

func (*ExcelWriter) GetWorkbookSheets

func (e *ExcelWriter) GetWorkbookSheets() string

func (*ExcelWriter) NewStyle

func (e *ExcelWriter) NewStyle() *Style

NewStyle

@Description: create new style
@receiver e
@return *Style

func (*ExcelWriter) OutputFile

func (e *ExcelWriter) OutputFile() error

type Ext

type Ext struct {
	XMLName xml.Name `xml:"a:ext"`
	Cx      string   `xml:"cx,attr"`
	Cy      string   `xml:"cy,attr"`
}

Ext 表示 <ext> 元素

type ExtLst

type ExtLst struct {
	Ext []*StyleExt `xml:"ext"`
}

type Family

type Family struct {
	Val string `xml:"val,attr"` // 字体名称值
}

type Fill

type Fill struct {
	PatternFill *PatternFill `xml:"patternFill"` // 填充模式
}

单个填充

type FillRect

type FillRect struct {
	XMLName xml.Name `xml:"a:fillRect"`
}

FillRect 表示 <fillRect> 元素

type Fills

type Fills struct {
	Count int     `xml:"count,attr"`
	Fill  []*Fill `xml:"fill"`
}

填充列表

type Font

type Font struct {
	B      bool      `xml:"b,omitempty"` // 加粗
	I      bool      `xml:"i,omitempty"` // 斜体
	Color  *Color    `xml:"color"`       // 颜色
	Sz     *FontSize `xml:"sz"`          // 字号
	Name   *FontName `xml:"name"`        // 字体名称
	Family *Family   `xml:"family"`
	Scheme *Scheme   `xml:"scheme"`
}

单个字体

type FontName

type FontName struct {
	Val string `xml:"val,attr"` // 字体名称值
}

字体名称

type FontSize

type FontSize struct {
	Val int `xml:"val,attr"` // 字号值
}

字体大小

type Fonts

type Fonts struct {
	Count int     `xml:"count,attr"`
	Font  []*Font `xml:"font"`
}

字体列表

type From

type From struct {
	XMLName xml.Name `xml:"xdr:from"`
	Col     string   `xml:"xdr:col"`
	ColOff  string   `xml:"xdr:colOff"`
	Row     string   `xml:"xdr:row"`
	RowOff  string   `xml:"xdr:rowOff"`
}

From 表示 <from> 元素

type HeaderFooter

type HeaderFooter struct {
	XMLName   xml.Name `xml:"headerFooter"`
	OddFooter string   `xml:"oddFooter,attr"`
}

type InlineString added in v1.3.0

type InlineString struct {
	XMLName xml.Name           `xml:"is"`
	T       string             `xml:"t"`
	R       []*InlineStringRun `xml:"r"`
}

func (*InlineString) GetText added in v1.3.0

func (s *InlineString) GetText() string

type InlineStringRun added in v1.3.0

type InlineStringRun struct {
	XMLName xml.Name `xml:"r"`
	T       string   `xml:"t"`
}

type MergeCell

type MergeCell struct {
	XMLName xml.Name `xml:"mergeCell"`
	Ref     string   `xml:"ref,attr"`
}

type MergeCells

type MergeCells struct {
	XMLName    xml.Name     `xml:"mergeCells"`
	Count      string       `xml:"count,attr"`
	MergeCells []*MergeCell `xml:"mergeCell"`
}

type NumFmt

type NumFmt struct {
	NumFmtID   int    `xml:"numFmtId,attr"`
	FormatCode string `xml:"formatCode,attr"`
}

单个数字格式

type NumFmts

type NumFmts struct {
	Count  int       `xml:"count,attr"`
	NumFmt []*NumFmt `xml:"numFmt"`
}

数字格式列表

type NvPicPr

type NvPicPr struct {
	XMLName  xml.Name  `xml:"xdr:nvPicPr"`
	CNvPr    *CNvPr    `xml:"xdr:cNvPr"`
	CNvPicPr *CNvPicPr `xml:"xdr:cNvPicPr"`
}

NvPicPr 表示 <nvPicPr> 元素

type Off

type Off struct {
	XMLName xml.Name `xml:"a:off"`
	X       string   `xml:"x,attr"`
	Y       string   `xml:"y,attr"`
}

Off 表示 <off> 元素

type Override

type Override struct {
	XMLName     xml.Name `xml:"Override"`
	PartName    string   `xml:"PartName,attr"`
	ContentType string   `xml:"ContentType,attr"`
}

type PageMargins

type PageMargins struct {
	XMLName xml.Name `xml:"pageMargins"`
	Left    string   `xml:"left,attr"`
	Right   string   `xml:"right,attr"`
	Top     string   `xml:"top,attr"`
	Bottom  string   `xml:"bottom,attr"`
	Header  string   `xml:"header,attr"`
	Footer  string   `xml:"footer,attr"`
}

type PageSetup

type PageSetup struct {
	XMLName            xml.Name `xml:"pageSetup"`
	PaperSize          string   `xml:"paperSize,attr"`
	Scale              string   `xml:"scale,attr"`
	FitToHeight        string   `xml:"fitToHeight,attr"`
	Orientation        string   `xml:"orientation,attr"`
	UsePrinterDefaults string   `xml:"usePrinterDefaults,attr"`
	BlackAndWhite      string   `xml:"blackAndWhite,attr"`
	HorizontalDpi      string   `xml:"horizontalDpi,attr"`
	VerticalDpi        string   `xml:"verticalDpi,attr"`
	Copies             string   `xml:"copies,attr"`
}

type PatternFill

type PatternFill struct {
	PatternType string `xml:"patternType,attr"` // 模式类型
	FgColor     *Color `xml:"fgColor"`          // 前景色
	BgColor     *Color `xml:"bgColor"`          // 背景色
}

填充模式

type PhoneticPr

type PhoneticPr struct {
	XMLName xml.Name `xml:"phoneticPr"`
	FontId  string   `xml:"fontId,attr"`
	Type    string   `xml:"type,attr"`
}

type Pic

type Pic struct {
	XMLName  xml.Name  `xml:"xdr:pic"`
	NvPicPr  *NvPicPr  `xml:"xdr:nvPicPr"`
	BlipFill *BlipFill `xml:"xdr:blipFill"`
	SpPr     *SpPr     `xml:"xdr:spPr"`
}

Pic 表示 <pic> 元素

type PicLocks

type PicLocks struct {
	XMLName        xml.Name `xml:"a:picLocks"`
	NoChangeAspect string   `xml:"noChangeAspect,attr"`
}

PicLocks 表示 <picLocks> 元素

type Picture

type Picture struct {
	File      []byte
	Filename  string
	Extension string
}

func (*Picture) OutputFile

func (p *Picture) OutputFile(filePath string) (string, error)

type PrstGeom

type PrstGeom struct {
	XMLName xml.Name `xml:"a:prstGeom"`
	Prst    string   `xml:"prst,attr"`
	AvLst   *AvLst   `xml:"avLst"`
}

PrstGeom 表示 <prstGeom> 元素

type R added in v1.2.3

type R struct {
	XMLName xml.Name `xml:"r"`
	T       string   `xml:"t"`
}

type RA16CreationId added in v1.2.2

type RA16CreationId struct {
	XMLName  xml.Name `xml:"creationId"`
	XmlnsA16 string   `xml:"xmlns:a16,attr"`
	Id       string   `xml:"id,attr"`
}

type RAExt added in v1.2.2

type RAExt struct {
	XMLName       xml.Name        `xml:"ext"`
	Uri           string          `xml:"uri,attr"`
	A16CreationId *RA16CreationId `xml:"creationId"`
}

type RAExtLst added in v1.2.2

type RAExtLst struct {
	XMLName xml.Name `xml:"extLst"`
	AExt    *RAExt   `xml:"ext"`
}

type RAvLst added in v1.2.2

type RAvLst struct {
	XMLName xml.Name `xml:"avLst"`
}

AvLst 表示 <avLst> 元素

type RBlip added in v1.2.2

type RBlip struct {
	XMLName xml.Name `xml:"blip"`
	XmlnsR  string   `xml:"xmlns:r,attr"`
	Embed   string   `xml:"embed,attr"`
}

Blip 表示 <blip> 元素

type RBlipFill added in v1.2.2

type RBlipFill struct {
	XMLName xml.Name  `xml:"blipFill"`
	Blip    *RBlip    `xml:"blip"`
	Stretch *RStretch `xml:"stretch"`
}

BlipFill 表示 <blipFill> 元素

type RCNvPicPr added in v1.2.2

type RCNvPicPr struct {
	XMLName  xml.Name   `xml:"cNvPicPr"`
	PicLocks *RPicLocks `xml:"picLocks"`
}

CNvPicPr 表示 <cNvPicPr> 元素

type RCNvPr added in v1.2.2

type RCNvPr struct {
	XMLName xml.Name  `xml:"cNvPr"`
	ID      string    `xml:"id,attr"`
	Name    string    `xml:"name,attr"`
	Desc    string    `xml:"descr,attr"`
	AExtLst *RAExtLst `xml:"extLst"`
}

CNvPr 表示 <cNvPr> 元素

type RClientData added in v1.2.2

type RClientData struct {
	XMLName xml.Name `xml:"clientData"`
}

ClientData 表示 <clientData> 元素

type RDrawing added in v1.2.2

type RDrawing struct {
	XMLName        xml.Name          `xml:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing wsDr"`
	Xmlns          string            `xml:"xmlns:xdr,attr"`
	XmlnsA         string            `xml:"xmlns:a,attr"`
	TwoCellAnchors []*RTwoCellAnchor `xml:"twoCellAnchor"`
}

type RExt added in v1.2.2

type RExt struct {
	XMLName xml.Name `xml:"ext"`
	Cx      string   `xml:"cx,attr"`
	Cy      string   `xml:"cy,attr"`
}

Ext 表示 <ext> 元素

type RFillRect added in v1.2.2

type RFillRect struct {
	XMLName xml.Name `xml:"fillRect"`
}

FillRect 表示 <fillRect> 元素

type RFont added in v1.2.3

type RFont struct {
	XMLName xml.Name `xml:"rFont"`
	Val     string   `xml:"val,attr"`
}

type RFrom added in v1.2.2

type RFrom struct {
	XMLName xml.Name `xml:"from"`
	Col     string   `xml:"col"`
	ColOff  string   `xml:"colOff"`
	Row     string   `xml:"row"`
	RowOff  string   `xml:"rowOff"`
}

From 表示 <from> 元素

type RNvPicPr added in v1.2.2

type RNvPicPr struct {
	XMLName  xml.Name   `xml:"nvPicPr"`
	CNvPr    *RCNvPr    `xml:"cNvPr"`
	CNvPicPr *RCNvPicPr `xml:"cNvPicPr"`
}

NvPicPr 表示 <nvPicPr> 元素

type ROff added in v1.2.2

type ROff struct {
	XMLName xml.Name `xml:"off"`
	X       string   `xml:"x,attr"`
	Y       string   `xml:"y,attr"`
}

Off 表示 <off> 元素

type RPic added in v1.2.2

type RPic struct {
	XMLName  xml.Name   `xml:"pic"`
	NvPicPr  *RNvPicPr  `xml:"nvPicPr"`
	BlipFill *RBlipFill `xml:"blipFill"`
	SpPr     *RSpPr     `xml:"spPr"`
}

Pic 表示 <pic> 元素

type RPicLocks added in v1.2.2

type RPicLocks struct {
	XMLName        xml.Name `xml:"picLocks"`
	NoChangeAspect string   `xml:"noChangeAspect,attr"`
}

PicLocks 表示 <picLocks> 元素

type RPr added in v1.2.3

type RPr struct {
	XMLName xml.Name `xml:"rPr"`
	Sz      *Sz      `xml:"sz"`
	RFont   *RFont   `xml:"rFont"`
	Charset *Charset `xml:"charset"`
}

type RPrstGeom added in v1.2.2

type RPrstGeom struct {
	XMLName xml.Name `xml:"prstGeom"`
	Prst    string   `xml:"prst,attr"`
	AvLst   *RAvLst  `xml:"avLst"`
}

PrstGeom 表示 <prstGeom> 元素

type RSpPr added in v1.2.2

type RSpPr struct {
	XMLName  xml.Name   `xml:"spPr"`
	Xfrm     *RXfrm     `xml:"xfrm"`
	PrstGeom *RPrstGeom `xml:"prstGeom"`
}

SpPr 表示 <spPr> 元素

type RStretch added in v1.2.2

type RStretch struct {
	XMLName  xml.Name   `xml:"stretch"`
	FillRect *RFillRect `xml:"fillRect"`
}

Stretch 表示 <stretch> 元素

type RTo added in v1.2.2

type RTo struct {
	XMLName xml.Name `xml:"to"`
	Col     string   `xml:"col"`
	ColOff  string   `xml:"colOff"`
	Row     string   `xml:"row"`
	RowOff  string   `xml:"rowOff"`
}

To 表示 <to> 元素

type RTwoCellAnchor added in v1.2.2

type RTwoCellAnchor struct {
	XMLName    xml.Name     `xml:"twoCellAnchor"`
	From       *RFrom       `xml:"from"`
	To         *RTo         `xml:"to"`
	Pic        *RPic        `xml:"pic"`
	ClientData *RClientData `xml:"clientData"`
}

TwoCellAnchor 表示 <twoCellAnchor> 元素

type RXfrm added in v1.2.2

type RXfrm struct {
	XMLName xml.Name `xml:"xfrm"`
	Off     *ROff    `xml:"off"`
	Ext     *RExt    `xml:"ext"`
}

Xfrm 表示 <xfrm> 元素

type Relationship

type Relationship struct {
	Id     string `xml:"Id,attr"`
	Type   string `xml:"Type,attr"`
	Target string `xml:"Target,attr"`
}

定义 Relationship 结构体

type Relationships

type Relationships struct {
	XMLName       xml.Name        `xml:"http://schemas.openxmlformats.org/package/2006/relationships Relationships"`
	Relationships []*Relationship `xml:"Relationship"`
}

定义 Relationships 结构体

type Row

type Row struct {
	XMLName      xml.Name `xml:"row"`
	RowNum       string   `xml:"r,attr"`     // 行号属性
	Spans        string   `xml:"spans,attr"` // 列范围
	Height       string   `xml:"ht,attr"`
	CustomHeight string   `xml:"customHeight,attr"`
	Cells        []*Cell  `xml:"c"`
}

func (*Row) SetHeight

func (r *Row) SetHeight(height float64)

type SI

type SI struct {
	XMLName xml.Name `xml:"si"`
	T       string   `xml:"t"`
	R       []*R     `xml:"r"`
}

func (*SI) GetText added in v1.2.3

func (s *SI) GetText() string

type SST

type SST struct {
	XMLName     xml.Name `xml:"sst"`
	Text        string   `xml:",chardata"`
	Xmlns       string   `xml:"xmlns,attr"`
	Count       string   `xml:"count,attr"`
	UniqueCount string   `xml:"uniqueCount,attr"`
	SI          []*SI    `xml:"si"`
}

定义对应的 XML 结构体

type Scheme

type Scheme struct {
	Val string `xml:"val,attr"`
}

type Selection

type Selection struct {
	XMLName    xml.Name `xml:"selection"`
	ActiveCell string   `xml:"activeCell,attr"`
	SqRef      string   `xml:"sqref,attr"`
}

type SharedString

type SharedString struct {
	Index  map[string]int
	Values []string
	Count  int
}

type Sheet

type Sheet struct {
	XMLName xml.Name `xml:"sheet"`
	Name    string   `xml:"name,attr"`
	SheetId int      `xml:"sheetId,attr"`
	RId     string   `xml:"r:id,attr"`
}

type SheetCol

type SheetCol struct {
	XMLName     xml.Name `xml:"col"`
	Min         string   `xml:"min,attr"`
	Max         string   `xml:"max,attr"`
	Width       string   `xml:"width,attr"`
	CustomWidth string   `xml:"customWidth,attr"`
	Collapsed   string   `xml:"collapsed,attr"`
}

type SheetCols

type SheetCols struct {
	XMLName xml.Name    `xml:"cols"`
	Cols    []*SheetCol `xml:"col"`
}

type SheetData

type SheetData struct {
	XMLName xml.Name `xml:"sheetData"`
	Rows    []*Row   `xml:"row"`
}

type SheetDrawing

type SheetDrawing struct {
	XMLName xml.Name `xml:"drawing"`
	RId     string   `xml:"r:id,attr"`
}

type SheetFormatPr

type SheetFormatPr struct {
	XMLName          xml.Name `xml:"sheetFormatPr"`
	DefaultRowHeight string   `xml:"defaultRowHeight,attr"`
	X14acDyDescent   string   `xml:"x14ac:dyDescent,attr"`
}

type SheetRow

type SheetRow struct {
	Index      int
	Cols       []*Col
	MergeCells string
}

type SheetView

type SheetView struct {
	XMLName        xml.Name `xml:"sheetView"`
	TabSelected    string   `xml:"tabSelected,attr"`
	WorkbookViewId string   `xml:"workbookViewId,attr"`
}

type SheetViews

type SheetViews struct {
	XMLName   xml.Name   `xml:"sheetViews"`
	SheetView *SheetView `xml:"sheetView"`
}

type Sheets

type Sheets struct {
	XMLName xml.Name `xml:"sheets"`
	Sheets  []Sheet  `xml:"sheet"`
}

type Side

type Side struct {
	Style string `xml:"style,attr"` // 边框样式
	Color *Color `xml:"color"`      // 边框颜色
}

单边边框

type SpPr

type SpPr struct {
	XMLName  xml.Name  `xml:"xdr:spPr"`
	Xfrm     *Xfrm     `xml:"a:xfrm"`
	PrstGeom *PrstGeom `xml:"a:prstGeom"`
}

SpPr 表示 <spPr> 元素

type Stretch

type Stretch struct {
	XMLName  xml.Name  `xml:"a:stretch"`
	FillRect *FillRect `xml:"a:fillRect"`
}

Stretch 表示 <stretch> 元素

type Style

type Style struct {
	Font      *Font
	Fill      *Fill
	Border    *Border
	Alignment *Alignment
	CellXf    *CellXf
}

func (*Style) SetAlignment

func (s *Style) SetAlignment(alignment *Alignment)

func (*Style) SetBorder

func (s *Style) SetBorder(border *Border)

func (*Style) SetFill

func (s *Style) SetFill(fill *Fill)

func (*Style) SetFont

func (s *Style) SetFont(font *Font)

type StyleExt

type StyleExt struct {
	Uri               string             `xml:"uri,attr"`
	XmlnsX14          string             `xml:"xmlns:x14,attr,omitempty"`
	XmlnsX15          string             `xml:"xmlns:x15,attr,omitempty"`
	X14SlicerStyles   *X14SlicerStyles   `xml:"x14:slicerStyles"`
	X15TimelineStyles *X15TimelineStyles `xml:"x15:timelineStyles"`
}

type StyleSheet

type StyleSheet struct {
	XMLName      xml.Name      `xml:"styleSheet"`
	Fonts        *Fonts        `xml:"fonts"`   // 字体列表
	Fills        *Fills        `xml:"fills"`   // 填充列表
	Borders      *Borders      `xml:"borders"` // 边框列表
	NumFmts      *NumFmts      `xml:"numFmts"` // 数字格式列表
	CellStyleXfs *CellStyleXfs `xml:"cellStyleXfs"`
	CellXfs      *CellXfs      `xml:"cellXfs"` // 单元格样式列表
	CellStyles   *CellStyles   `xml:"cellStyles"`
	DxFs         *DxFs         `xml:"dxfs"`
	TableStyles  *TableStyles  `xml:"tableStyles"`
	ExtList      *ExtLst       `xml:"extLst"`
}

定义样式表的根结构体

func NewDefaultCellStyle

func NewDefaultCellStyle() *StyleSheet

type Sz added in v1.2.3

type Sz struct {
	XMLName xml.Name `xml:"sz"`
	Val     string   `xml:"val,attr"`
}

type TableStyles

type TableStyles struct {
	Count             int    `xml:"count,attr"`
	DefaultTableStyle string `xml:"defaultTableStyle,attr"`
	DefaultPivotStyle string `xml:"defaultPivotStyle,attr"`
}

type To

type To struct {
	XMLName xml.Name `xml:"xdr:to"`
	Col     string   `xml:"xdr:col"`
	ColOff  string   `xml:"xdr:colOff"`
	Row     string   `xml:"xdr:row"`
	RowOff  string   `xml:"xdr:rowOff"`
}

To 表示 <to> 元素

type TwoCellAnchor

type TwoCellAnchor struct {
	XMLName    xml.Name    `xml:"xdr:twoCellAnchor"`
	From       *From       `xml:"xdr:from"`
	To         *To         `xml:"xdr:to"`
	Pic        *Pic        `xml:"xdr:pic"`
	ClientData *ClientData `xml:"xdr:clientData"`
}

TwoCellAnchor 表示 <twoCellAnchor> 元素

type WorkSheet added in v1.2.1

type WorkSheet struct {
	SheetId string
	Name    string
}

type Workbook

type Workbook struct {
	XMLName      xml.Name     `xml:"workbook"`
	Sheets       Sheets       `xml:"sheets"`
	DefinedNames DefinedNames `xml:"definedNames"`
	CalcPr       CalcPr       `xml:"calcPr"`
	Xmlns        string       `xml:"xmlns,attr"`
	XmlnsXsi     string       `xml:"xmlns:xsi,attr"`
	XmlnsR       string       `xml:"xmlns:r,attr"`
}

type Worksheet

type Worksheet struct {
	XMLName       xml.Name          `xml:"worksheet"`
	Xmlns         string            `xml:"xmlns,attr"`
	XmlnsR        string            `xml:"xmlns:r,attr"`
	XmlnsMc       string            `xml:"xmlns:mc,attr"`
	McIgnorable   string            `xml:"mc:Ignorable,attr"`
	XmlnsX14ac    string            `xml:"xmlns:x14ac,attr"`
	XmlnsXr       string            `xml:"xmlns:xr,attr"`
	XmlnsXr2      string            `xml:"xmlns:xr2,attr"`
	XmlnsXr3      string            `xml:"xmlns:xr3,attr"`
	XrUid         string            `xml:"xr:uid,attr"`
	Dimension     *Dimension        `xml:"dimension"`
	SheetViews    *SheetViews       `xml:"sheetViews"`
	SheetFormatPr *SheetFormatPr    `xml:"sheetFormatPr"`
	SheetCols     *SheetCols        `xml:"cols"`
	SheetData     *SheetData        `xml:"sheetData"`
	MergeCells    *MergeCells       `xml:"mergeCells,omitempty"`
	PhoneticPr    *PhoneticPr       `xml:"phoneticPr"`
	PageMargins   *PageMargins      `xml:"pageMargins"`
	PageSetup     *PageSetup        `xml:"pageSetup"`
	HeaderFooter  *HeaderFooter     `xml:"headerFooter"`
	SheetDrawing  *SheetDrawing     `xml:"drawing,omitempty"`
	Name          string            `xml:"-"`
	Title         string            `xml:"-"`
	ExcelWriter   *ExcelWriter      `xml:"-"`
	CellStyle     map[string]int    `xml:"-"`
	Images        map[string]string `xml:"-"`
	SheetId       int               `xml:"-"`
}

定义与 XML 结构对应的结构体

func (*Worksheet) AddCell

func (w *Worksheet) AddCell(value string, colIndex, rowIndex int) *Cell

func (*Worksheet) AddImage

func (w *Worksheet) AddImage(cell string, imagePath string)

func (*Worksheet) AddRow

func (w *Worksheet) AddRow(cols []string) *Row

func (*Worksheet) CreateDimension

func (w *Worksheet) CreateDimension()

func (*Worksheet) CreateHeaderFooter

func (w *Worksheet) CreateHeaderFooter(footer string)

func (*Worksheet) CreatePageMargins

func (w *Worksheet) CreatePageMargins(left, right, top, bottom, header, footer string)

func (*Worksheet) CreatePageSetup

func (w *Worksheet) CreatePageSetup()

func (*Worksheet) CreatePhoneticPr

func (w *Worksheet) CreatePhoneticPr()

func (*Worksheet) CreateSheetFormatPr

func (w *Worksheet) CreateSheetFormatPr(defaultRowHeight, dyDescent string)

func (*Worksheet) CreateSheetViews

func (w *Worksheet) CreateSheetViews(tabSelected, workbookViewId int)

func (*Worksheet) DefaultPageMargins

func (w *Worksheet) DefaultPageMargins()

func (*Worksheet) GetImageCreationId

func (w *Worksheet) GetImageCreationId(id int) string

func (*Worksheet) GetMaxColIndex

func (w *Worksheet) GetMaxColIndex() int

func (*Worksheet) GetMaxRowIndex

func (w *Worksheet) GetMaxRowIndex() int

func (*Worksheet) GetMergeCellByCell

func (w *Worksheet) GetMergeCellByCell(cell string) (bool, string)

func (*Worksheet) GetMergeCells

func (w *Worksheet) GetMergeCells() []string

func (*Worksheet) GetSheetName

func (w *Worksheet) GetSheetName() string

func (*Worksheet) GetUUID

func (w *Worksheet) GetUUID(sheetId int) string

func (*Worksheet) GetWorksheetPath

func (w *Worksheet) GetWorksheetPath() string

func (*Worksheet) Init

func (w *Worksheet) Init()

func (*Worksheet) MergeCell

func (w *Worksheet) MergeCell(from, to string)

func (*Worksheet) NewImage

func (w *Worksheet) NewImage(cell string, imageId int, rId string) *TwoCellAnchor

func (*Worksheet) SetCellStyle

func (w *Worksheet) SetCellStyle(topLeftCell, bottomRightCell string, style *Style)

func (*Worksheet) SetCellWidth

func (w *Worksheet) SetCellWidth(minCell, maxCell int, width float64)

func (*Worksheet) SetTitle

func (w *Worksheet) SetTitle(title string)

type X14SlicerStyles

type X14SlicerStyles struct {
	XMLName            xml.Name `xml:"x14:slicerStyles"`
	DefaultSlicerStyle string   `xml:"defaultSlicerStyle,attr"`
}

type X15TimelineStyles

type X15TimelineStyles struct {
	XMLName              xml.Name `xml:"x15:timelineStyles"`
	DefaultTimelineStyle string   `xml:"defaultTimelineStyle,attr"`
}

type Xfrm

type Xfrm struct {
	XMLName xml.Name `xml:"a:xfrm"`
	Off     *Off     `xml:"a:off"`
	Ext     *Ext     `xml:"a:ext"`
}

Xfrm 表示 <xfrm> 元素

Jump to

Keyboard shortcuts

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