Documentation
¶
Index ¶
- Constants
- Variables
- func CellNameToCoordinates(cellName string) (col int, row int)
- func ColumnName(columnNumber int) (columnName string)
- func ColumnNumber(columnName string) (columnNumber int)
- func ColumnRange(columnRange string) (min, max int)
- func CoordinatesToCellName(col, row int) string
- func ExcelTimeToTime(excelTime decimal.Decimal) time.Time
- func TimeToExcelTime(t time.Time) decimal.Decimal
- type Alignment
- type AlignmentReadingOrder
- type Axis
- type Border
- type BorderStyle
- type Cell
- type Color
- type File
- type Fill
- type FillPattern
- type Font
- type FontCharSet
- type FontFamilyNumbering
- type FontScheme
- type FontUnderline
- type FontVerticalTextAlignment
- type HorizontalAlignment
- type NumberFormat
- type Option
- type Sheet
- type Style
- type ThemeColor
- type VerticalAlignment
Constants ¶
View Source
const ( VariantTypeVariant = "variant" VariantTypeVTLPSTR = "lpstr" )
VariantTypes
View Source
const BuiltInNumFmtMax = 163 // The maximum number of built-in number formats.
Variables ¶
View Source
var ( DefaultSheetName = "Sheet1" DefaultFontName = "Microsoft YaHei" DefaultFontSize = 11 )
Functions ¶
func CellNameToCoordinates ¶
CellNameToCoordinates convert cell name to [col, row] coordinates
Example:
xlsx.CellNameToCoordinates("A1") // returns 1, 1 xlsx.CellNameToCoordinates("B5") // returns 2, 5
func ColumnName ¶
ColumnName convert the column number to column name
Example:
xlsx.ColumnName(51) // returns "AY"
func ColumnNumber ¶
ColumnNumber convert the column name to column number
Example:
xlsx.ColumnNumber("AY") // returns 51
func ColumnRange ¶
ColumnRange parse column range
Example:
xlsx.ColumnRange("A:Z") // returns 1, 26 xlsx.ColumnRange("Z:A") // returns 1, 26
func CoordinatesToCellName ¶
CoordinatesToCellName convert [col, row] coordinates to cell name
Example:
xlsx.CoordinatesToCellName(1, 1) // returns "A1"
func ExcelTimeToTime ¶
ExcelTimeToTime convert excel time format to time.Time
Types ¶
type Alignment ¶
type Alignment struct { Horizontal HorizontalAlignment // Specifies the type of horizontal alignment in cells. Indent int // An integer value, where an increment of 1 represents 3 spaces. Indicates the number of spaces (of the normal style font) of indentation for text in a cell. JustifyLastLine bool // A boolean value indicating if the cells justified or distributed alignment should be used on the last line of text. ReadingOrder AlignmentReadingOrder // An integer value indicating whether the reading order (bidirectionality) of the cell is left-to-right, right-to-left, or context dependent. RelativeIndent int // An integer value (used only in a dxf element) to indicate the additional number of spaces of indentation to adjust for text in a cell. ShrinkToFit bool // A boolean value indicating if the displayed text in the cell should be shrunk to fit the cell width. Not applicable when a cell contains multiple lines of text. TextRotation int // Text rotation in cells. Expressed in degrees. Values range from 0 to 180. The first letter of the text is considered the center-point of the arc. Vertical VerticalAlignment // Vertical alignment in cells. WrapText bool // A boolean value indicating if the text in a cell should be line-wrapped within the cell. }
type AlignmentReadingOrder ¶
type AlignmentReadingOrder int
const ( AlignmentReadingOrderContextDependent AlignmentReadingOrder = iota AlignmentReadingOrderLeftToRight AlignmentReadingOrderRightToLeft )
type Border ¶
type Border struct { OutsideBorder BorderStyle OutsideBorderColor Color InsideBorder BorderStyle InsideBorderColor Color LeftBorder BorderStyle LeftBorderColor Color RightBorder BorderStyle RightBorderColor Color TopBorder BorderStyle TopBorderColor Color BottomBorder BorderStyle BottomBorderColor Color DiagonalBorder BorderStyle DiagonalBorderColor Color DiagonalUp bool DiagonalDown bool Outline bool }
type BorderStyle ¶
type BorderStyle string
const ( BorderStyleNone BorderStyle = "none" BorderStyleThin BorderStyle = "thin" BorderStyleMedium BorderStyle = "medium" BorderStyleDashed BorderStyle = "dashed" BorderStyleDotted BorderStyle = "dotted" BorderStyleThick BorderStyle = "thick" BorderStyleDouble BorderStyle = "double" BorderStyleHair BorderStyle = "hair" BorderStyleMediumDashed BorderStyle = "mediumDashed" BorderStyleDashDot BorderStyle = "dashDot" BorderStyleMediumDashDot BorderStyle = "mediumDashDot" BorderStyleDashDotDot BorderStyle = "dashDotDot" BorderStyleMediumDashDotDot BorderStyle = "mediumDashDotDot" BorderStyleSlantDashDot BorderStyle = "slantDashDot" )
type Cell ¶
type Cell interface { // Row cell row number Row() int // Col cell col number Col() int // Axis cell axis Axis() Axis // SetValue provides to set the value of a cell // Allow Types: // int // int8 // int16 // int32 // int64 // uint // uint8 // uint16 // uint32 // uint64 // float32 // float64 // string // bool // time.Time // time.Duration // []byte // decimal.Decimal // // Example: // cell.SetValue(100) // cell.SetValue("Hello") // cell.SetValue(3.14) SetValue(value any) Cell // SetIntValue set cell for int type SetIntValue(value int) Cell // GetIntValue get cell value with int type GetIntValue() int // SetFloatValue set cell for decimal.Decimal type SetFloatValue(value decimal.Decimal) Cell // SetFloatValuePrec set cell for decimal.Decimal type with pres SetFloatValuePrec(value decimal.Decimal, prec int) Cell // GetFloatValue get cell value with decimal.Decimal type GetFloatValue() decimal.Decimal // SetStringValue set cell value for string type SetStringValue(value string) Cell // GetStringValue get cell value with string type GetStringValue() string // SetBoolValue set cell value for bool type SetBoolValue(value bool) Cell // GetBoolValue get cell value with bool type GetBoolValue() bool // SetDefaultValue set cell value without any type SetDefaultValue(value string) Cell // SetTimeValue set cell value for time.Time type // // Example: // cell.SetTimeValue(time.Now()) SetTimeValue(value time.Time) Cell // GetTimeValue get cell value with time.Time type GetTimeValue() time.Time // SetDateValue set cell value for time.Time type with date format // // Example: // cell.SetDateValue(time.Now()) SetDateValue(value time.Time) Cell // SetDurationValue set cell value for time.Duration type // // Example: // cell.SetDurationValue(10 * time.Second) SetDurationValue(value time.Duration) Cell // GetDurationValue get cell value with time.Duration type GetDurationValue() time.Duration // SetFormula set cell formula // // Example: // cell.SetFormula("SUM(A1:A10)") SetFormula(formula string) Cell // GetFormula get cell formula GetFormula() string // SetNumberFormat set cell number format with format code // https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.numberingformat?view=openxml-2.8.1 // // Example: // cell.SetNumberFormat("yyyy-mm-dd hh:mm:ss") SetNumberFormat(formatCode string) Cell // GetStyle get cell style GetStyle() Style // SetStyle set cell style SetStyle(style Style) Cell // SetCellBorder set cell border // // Example: // cell.SetCellBorder(BorderStyleThin, Color{Color: "00FF00"}, false, true, false, true) SetCellBorder(borderStyle BorderStyle, borderColor Color, top, right, bottom, left bool) Cell }
Cell cell operator
type Color ¶
type Color struct { ThemeColor ThemeColor Indexed int Tint decimal.Decimal Color string }
type File ¶
type File interface { // SaveFile save xlsx file SaveFile(name string) error // Save save to steam Save(w io.Writer) error // OpenSheet open a exist Sheet by name // // Example: // // sheet := file.OpenSheet("Sheet1") // // return nil if sheet not exist OpenSheet(name string) Sheet // NewSheet create a new Sheet with sheet name // Example: // // sheet := file.NewSheet("Sheet2") NewSheet(name string) Sheet // Sheets return all sheet for operator Sheets() []Sheet }
File define for operation xlsx file
type Fill ¶
type Fill struct { BackgroundColor Color PatternColor Color PatternType FillPattern }
type FillPattern ¶
type FillPattern string
const ( FillPatternNone FillPattern = "none" FillPatternSolid FillPattern = "solid" FillPatternMediumGray FillPattern = "mediumGray" FillPatternDarkGray FillPattern = "darkGray" FillPatternLightGray FillPattern = "lightGray" FillPatternDarkHorizontal FillPattern = "darkHorizontal" FillPatternDarkVertical FillPattern = "darkVertical" FillPatternDarkDown FillPattern = "darkDown" FillPatternDarkUp FillPattern = "darkUp" FillPatternDarkGrid FillPattern = "darkGrid" FillPatternDarkTrellis FillPattern = "darkTrellis" FillPatternLightHorizontal FillPattern = "lightHorizontal" FillPatternLightVertical FillPattern = "lightVertical" FillPatternLightDown FillPattern = "lightDown" FillPatternLightUp FillPattern = "lightUp" FillPatternLightGrid FillPattern = "lightGrid" FillPatternLightTrellis FillPattern = "lightTrellis" FillPatternGray125 FillPattern = "gray125" FillPatternGray0625 FillPattern = "gray0625" )
type Font ¶
type Font struct { Bold bool Italic bool Underline FontUnderline Strikethrough bool VerticalAlignment FontVerticalTextAlignment Shadow bool FontSize int FontColor Color FontName string FontFamilyNumbering FontFamilyNumbering FontCharSet FontCharSet FontScheme FontScheme Condense bool Extend bool Outline bool }
type FontCharSet ¶
type FontCharSet int
const ( FontCharSetAnsi FontCharSet = 0 // ASCII character set. FontCharSetDefault FontCharSet = 1 // System default character set. FontCharSetSymbol FontCharSet = 2 // Symbol character set. FontCharSetMac FontCharSet = 77 // Characters used by Macintosh. FontCharSetShiftJIS FontCharSet = 128 // Japanese character set. FontCharSetHangul FontCharSet = 129 // Korean character set. FontCharSetHangeul FontCharSet = 129 // Another common spelling of the Korean character set. FontCharSetJohab FontCharSet = 130 // Korean character set. FontCharSetGB2312 FontCharSet = 134 // Chinese character set used in mainland China. FontCharSetChineseBig5 FontCharSet = 136 // Chinese character set used mostly in Hong Kong SAR and Taiwan. FontCharSetGreek FontCharSet = 161 // Greek character set. FontCharSetTurkish FontCharSet = 162 // Turkish character set. FontCharSetVietnamese FontCharSet = 163 // Vietnamese character set. FontCharSetHebrew FontCharSet = 177 // Hebrew character set. FontCharSetArabic FontCharSet = 178 // Arabic character set. FontCharSetBaltic FontCharSet = 186 // Baltic character set. FontCharSetRussian FontCharSet = 204 // Russian character set. FontCharSetThai FontCharSet = 222 // Thai character set. FontCharSetEastEurope FontCharSet = 238 // Eastern European character set. FontCharSetOEM FontCharSet = 255 // Extended ASCII character set used with disk operating system (DOS) and some Microsoft Windows fonts. )
type FontFamilyNumbering ¶
type FontFamilyNumbering int
const ( FontFamilyNumberingNotApplicable FontFamilyNumbering = iota FontFamilyNumberingRoman FontFamilyNumberingSwiss FontFamilyNumberingModern FontFamilyNumberingScript FontFamilyNumberingDecorative )
type FontScheme ¶
type FontScheme string
const ( FontSchemeNone FontScheme = "none" // Not a part of theme scheme. FontSchemeMajor // A major font of a theme, generally used for headings. FontSchemeMinor // A minor font of a theme, generally used to body and paragraphs. )
type FontUnderline ¶
type FontUnderline string
const ( FontUnderlineDouble FontUnderline = "double" FontUnderlineDoubleAccounting FontUnderline = "doubleAccounting" FontUnderlineNone FontUnderline = "none" FontUnderlineSingle FontUnderline = "single" FontUnderlineSingleAccounting FontUnderline = "singleAccounting" )
type FontVerticalTextAlignment ¶
type FontVerticalTextAlignment string
const ( FontVerticalTextAlignmentBaseline FontVerticalTextAlignment = "baseline" FontVerticalTextAlignmentSubscript FontVerticalTextAlignment = "subscript" FontVerticalTextAlignmentSuperscript FontVerticalTextAlignment = "superscript" )
type HorizontalAlignment ¶
type HorizontalAlignment string
const ( HorizontalAlignmentGeneral HorizontalAlignment = "general" HorizontalAlignmentCenter HorizontalAlignment = "center" HorizontalAlignmentLeft HorizontalAlignment = "left" HorizontalAlignmentRight HorizontalAlignment = "right" HorizontalAlignmentFill HorizontalAlignment = "fill" HorizontalAlignmentJustify HorizontalAlignment = "justify" HorizontalAlignmentCenterContinuous HorizontalAlignment = "centerContinuous" HorizontalAlignmentDistributed HorizontalAlignment = "distributed" )
type NumberFormat ¶
type Sheet ¶
type Sheet interface { // Name sheet name Name() string // SetCellValue set cell value // // Example: // sheet.SetCellValue(1, 1, "val") // A1 => "val" // sheet.SetCellValue(2, 3, 98.01) // B3 => 98.01 // sheet.SetCellValue(3, 1, 1000) // C1 => 1000 // sheet.SetCellValue(4, 4, time.Now()) // D4 => "2021-03-11 05:19" SetCellValue(col, row int, value any) Cell // SetAxisCellValue set cell value // // Example: // sheet.SetAxisCellValue("A1", "val") // A1 => "val" // sheet.SetAxisCellValue("B3", 98.01) // B3 => 98.01 // sheet.SetAxisCellValue("C1", 1000) // C1 => 1000 // sheet.SetAxisCellValue("D4", time.Now()) // D4 => "2021-03-11 05:19" SetAxisCellValue(axis Axis, value any) Cell // Cell get cell by cell col and row Cell(col, row int) Cell // AxisCell get cell by cell name AxisCell(axis Axis) Cell // SetColumnWidth set column width // // Example: // sheet.SetColumnWidth("A:B", 20) SetColumnWidth(columnRange string, width decimal.Decimal) Sheet // GetColumnWidth get column width // // Example: // sheet.GetColumnWidth("A") // returns 20 GetColumnWidth(columnName string) decimal.Decimal // MergeCell merge cell // // Example: // sheet.MergeCell("A1", "B1") MergeCell(start Axis, end Axis) Sheet // GetCellStyle get cell style GetCellStyle(col, row int) Style // GetAxisCellStyle get cell style GetAxisCellStyle(axis Axis) Style // SetCellStyle set cell style SetCellStyle(col, row int, style Style) Sheet // SetAxisCellStyle set cell style SetAxisCellStyle(axis Axis, style Style) Sheet // GetColumnStyle get column style GetColumnStyle(col int) Style // SetColumnStyle set column style SetColumnStyle(col int, style Style) Sheet // SetCellBorder set cell border // // Example: // sheet.SetCellBorder(1, 1, BorderStyleThin, Color{Color: "FF0000"}, false, true, false, true) SetCellBorder(col, row int, borderStyle BorderStyle, borderColor Color, top, right, bottom, left bool) Sheet // SetAxisCellBorder set cell border // // Example: // sheet.SetAxisCellBorder("A1", BorderStyleThin, Color{Color: "FF0000"}, false, true, false, true) SetAxisCellBorder(axis Axis, borderStyle BorderStyle, borderColor Color, top, right, bottom, left bool) Sheet // MaxRow get max row MaxRow() int }
Sheet sheet operator
type ThemeColor ¶
type ThemeColor int
const ( ThemeColorDark1 ThemeColor = iota ThemeColorLight1 ThemeColorDark2 ThemeColorLight2 ThemeColorAccent1 ThemeColorAccent2 ThemeColorAccent3 ThemeColorAccent4 ThemeColorAccent5 ThemeColorAccent6 ThemeColorHyperlink ThemeColorFollowedHyperlink )
type VerticalAlignment ¶
type VerticalAlignment string
const ( VerticalAlignmentGeneral VerticalAlignment = "bottom" VerticalAlignmentTop VerticalAlignment = "top" VerticalAlignmentBottom VerticalAlignment = "bottom" VerticalAlignmentCenter VerticalAlignment = "center" VerticalAlignmentJustify VerticalAlignment = "justify" VerticalAlignmentDistributed VerticalAlignment = "distributed" )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.