Documentation
¶
Index ¶
- type A16CreationId
- type AExt
- type AExtLst
- type Alignment
- type AvLst
- type Blip
- type BlipFill
- type Border
- type Borders
- type CNvPicPr
- type CNvPr
- type CalcPr
- type Cell
- type CellStyle
- type CellStyleXfs
- type CellStyles
- type CellXf
- type CellXfs
- type Charset
- type ClientData
- type Col
- type Color
- type ContentType
- type Default
- type DefinedName
- type DefinedNames
- type Dimension
- type Drawing
- type DxFs
- type ExcelWriter
- func (e *ExcelWriter) AddFile(filename string, content []byte) error
- func (e *ExcelWriter) AddSharedString(str string) int
- func (e *ExcelWriter) Close() error
- func (e *ExcelWriter) CreateContentType()
- func (e *ExcelWriter) CreateDrawing()
- func (e *ExcelWriter) CreateSharedString()
- func (e *ExcelWriter) CreateWorksheet() *Worksheet
- func (e *ExcelWriter) CreateWorksheetRelationship()
- func (e *ExcelWriter) GetAppSheets() string
- func (e *ExcelWriter) GetBorderId(style *Style) int
- func (e *ExcelWriter) GetCellXfId(style *Style) int
- func (e *ExcelWriter) GetExcelFileXml() (map[string]string, error)
- func (e *ExcelWriter) GetFillId(style *Style) int
- func (e *ExcelWriter) GetFontId(style *Style) int
- func (e *ExcelWriter) GetSharedStringIndex(str string) int
- func (e *ExcelWriter) GetWorkbookSheets() string
- func (e *ExcelWriter) NewStyle() *Style
- func (e *ExcelWriter) OutputFile() error
- type Ext
- type ExtLst
- type Family
- type Fill
- type FillRect
- type Fills
- type Font
- type FontName
- type FontSize
- type Fonts
- type From
- type HeaderFooter
- type InlineString
- type InlineStringRun
- type MergeCell
- type MergeCells
- type NumFmt
- type NumFmts
- type NvPicPr
- type Off
- type Override
- type PageMargins
- type PageSetup
- type PatternFill
- type PhoneticPr
- type Pic
- type PicLocks
- type Picture
- type PrstGeom
- type R
- type RA16CreationId
- type RAExt
- type RAExtLst
- type RAvLst
- type RBlip
- type RBlipFill
- type RCNvPicPr
- type RCNvPr
- type RClientData
- type RDrawing
- type RExt
- type RFillRect
- type RFont
- type RFrom
- type RNvPicPr
- type ROff
- type RPic
- type RPicLocks
- type RPr
- type RPrstGeom
- type RSpPr
- type RStretch
- type RTo
- type RTwoCellAnchor
- type RXfrm
- type Relationship
- type Relationships
- type Row
- type SI
- type SST
- type Scheme
- type Selection
- type SharedString
- type Sheet
- type SheetCol
- type SheetCols
- type SheetData
- type SheetDrawing
- type SheetFormatPr
- type SheetRow
- type SheetView
- type SheetViews
- type Sheets
- type Side
- type SpPr
- type Stretch
- type Style
- type StyleExt
- type StyleSheet
- type Sz
- type TableStyles
- type To
- type TwoCellAnchor
- type WorkSheet
- type Workbook
- type Worksheet
- func (w *Worksheet) AddCell(value string, colIndex, rowIndex int) *Cell
- func (w *Worksheet) AddImage(cell string, imagePath string)
- func (w *Worksheet) AddRow(cols []string) *Row
- func (w *Worksheet) CreateDimension()
- func (w *Worksheet) CreateHeaderFooter(footer string)
- func (w *Worksheet) CreatePageMargins(left, right, top, bottom, header, footer string)
- func (w *Worksheet) CreatePageSetup()
- func (w *Worksheet) CreatePhoneticPr()
- func (w *Worksheet) CreateSheetFormatPr(defaultRowHeight, dyDescent string)
- func (w *Worksheet) CreateSheetViews(tabSelected, workbookViewId int)
- func (w *Worksheet) DefaultPageMargins()
- func (w *Worksheet) GetImageCreationId(id int) string
- func (w *Worksheet) GetMaxColIndex() int
- func (w *Worksheet) GetMaxRowIndex() int
- func (w *Worksheet) GetMergeCellByCell(cell string) (bool, string)
- func (w *Worksheet) GetMergeCells() []string
- func (w *Worksheet) GetSheetName() string
- func (w *Worksheet) GetUUID(sheetId int) string
- func (w *Worksheet) GetWorksheetPath() string
- func (w *Worksheet) Init()
- func (w *Worksheet) MergeCell(from, to string)
- func (w *Worksheet) NewImage(cell string, imageId int, rId string) *TwoCellAnchor
- func (w *Worksheet) SetCellStyle(topLeftCell, bottomRightCell string, style *Style)
- func (w *Worksheet) SetCellWidth(minCell, maxCell int, width float64)
- func (w *Worksheet) SetTitle(title string)
- type X14SlicerStyles
- type X15TimelineStyles
- type Xfrm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type A16CreationId ¶
type AExt ¶
type AExt struct {
XMLName xml.Name `xml:"a:ext"`
Uri string `xml:"uri,attr"`
A16CreationId *A16CreationId `xml:"a16:creationId"`
}
type Alignment ¶
type Alignment struct {
Horizontal string `xml:"horizontal,attr"` // 水平对齐
Vertical string `xml:"vertical,attr"` // 垂直对齐
}
对齐方式
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 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 CellStyleXfs ¶
type CellStyles ¶
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 ClientData ¶
ClientData 表示 <clientData> 元素
type Color ¶
type Color struct {
RGB string `xml:"rgb,attr,omitempty"` // 颜色值 (ARGB 格式)
Theme string `xml:"theme,attr,omitempty"`
}
字体颜色
type ContentType ¶
type DefinedName ¶
type DefinedNames ¶
type DefinedNames struct {
XMLName xml.Name `xml:"definedNames"`
DefinedName []DefinedName `xml:"definedName"`
}
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 ExcelWriter ¶
type ExcelWriter struct {
File *os.File
Writer *zip.Writer
WorkSheets []*Worksheet
Relationships *Relationships
ContentTypes *ContentType
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 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 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 {
}
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 MergeCells ¶
type NvPicPr ¶
type NvPicPr struct {
XMLName xml.Name `xml:"xdr:nvPicPr"`
CNvPr *CNvPr `xml:"xdr:cNvPr"`
CNvPicPr *CNvPicPr `xml:"xdr:cNvPicPr"`
}
NvPicPr 表示 <nvPicPr> 元素
type PageMargins ¶
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 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 PrstGeom ¶
type PrstGeom struct {
XMLName xml.Name `xml:"a:prstGeom"`
Prst string `xml:"prst,attr"`
AvLst *AvLst `xml:"avLst"`
}
PrstGeom 表示 <prstGeom> 元素
type RA16CreationId ¶ added in v1.2.2
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 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 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
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 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 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 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 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 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 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 SharedString ¶
type SharedString struct {
}
type SheetDrawing ¶
type SheetFormatPr ¶
type SheetViews ¶
type SpPr ¶
type SpPr struct {
XMLName xml.Name `xml:"xdr:spPr"`
Xfrm *Xfrm `xml:"a:xfrm"`
PrstGeom *PrstGeom `xml:"a:prstGeom"`
}
SpPr 表示 <spPr> 元素
type Style ¶
func (*Style) SetAlignment ¶
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 TableStyles ¶
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 ¶
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"`
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) CreateDimension ¶
func (w *Worksheet) CreateDimension()
func (*Worksheet) CreateHeaderFooter ¶
func (*Worksheet) CreatePageMargins ¶
func (*Worksheet) CreatePageSetup ¶
func (w *Worksheet) CreatePageSetup()
func (*Worksheet) CreatePhoneticPr ¶
func (w *Worksheet) CreatePhoneticPr()
func (*Worksheet) CreateSheetFormatPr ¶
func (*Worksheet) CreateSheetViews ¶
func (*Worksheet) DefaultPageMargins ¶
func (w *Worksheet) DefaultPageMargins()
func (*Worksheet) GetImageCreationId ¶
func (*Worksheet) GetMaxColIndex ¶
func (*Worksheet) GetMaxRowIndex ¶
func (*Worksheet) GetMergeCellByCell ¶
func (*Worksheet) GetMergeCells ¶
func (*Worksheet) GetSheetName ¶
func (*Worksheet) GetWorksheetPath ¶
func (*Worksheet) NewImage ¶
func (w *Worksheet) NewImage(cell string, imageId int, rId string) *TwoCellAnchor