excel

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileIsNotWritable added in v0.10.3

func FileIsNotWritable(absolutePath string) bool

FileIsNotReadable checks if a file is not writable

func NormalizeRange added in v0.9.0

func NormalizeRange(rangeStr string) string

func ParseRange

func ParseRange(rangeStr string) (int, int, int, int, error)

parseRange parses Excel's range string (e.g. A1:C10 or A1)

Types

type Border added in v0.12.0

type Border struct {
	Type  BorderType  `yaml:"type"`
	Style BorderStyle `yaml:"style,omitempty"`
	Color string      `yaml:"color,omitempty"`
}

type BorderStyle added in v0.11.0

type BorderStyle string

BorderStyle represents border style constants

const (
	BorderStyleNone             BorderStyle = "none"
	BorderStyleContinuous       BorderStyle = "continuous"
	BorderStyleDash             BorderStyle = "dash"
	BorderStyleDot              BorderStyle = "dot"
	BorderStyleDouble           BorderStyle = "double"
	BorderStyleDashDot          BorderStyle = "dashDot"
	BorderStyleDashDotDot       BorderStyle = "dashDotDot"
	BorderStyleSlantDashDot     BorderStyle = "slantDashDot"
	BorderStyleMediumDashDot    BorderStyle = "mediumDashDot"
	BorderStyleMediumDashDotDot BorderStyle = "mediumDashDotDot"
)

func BorderStyleValues added in v0.12.0

func BorderStyleValues() []BorderStyle

func (BorderStyle) MarshalText added in v0.12.0

func (b BorderStyle) MarshalText() ([]byte, error)

func (BorderStyle) String added in v0.12.0

func (b BorderStyle) String() string

type BorderType added in v0.12.0

type BorderType string

BorderType represents border direction

const (
	BorderTypeLeft         BorderType = "left"
	BorderTypeRight        BorderType = "right"
	BorderTypeTop          BorderType = "top"
	BorderTypeBottom       BorderType = "bottom"
	BorderTypeDiagonalDown BorderType = "diagonalDown"
	BorderTypeDiagonalUp   BorderType = "diagonalUp"
)

func BorderTypeValues added in v0.12.0

func BorderTypeValues() []BorderType

func (BorderType) MarshalText added in v0.12.0

func (b BorderType) MarshalText() ([]byte, error)

func (BorderType) String added in v0.12.0

func (b BorderType) String() string

type CellStyle added in v0.11.0

type CellStyle struct {
	Border        []Border   `yaml:"border,omitempty"`
	Font          *FontStyle `yaml:"font,omitempty"`
	Fill          *FillStyle `yaml:"fill,omitempty"`
	NumFmt        *string    `yaml:"numFmt,omitempty"`
	DecimalPlaces *int       `yaml:"decimalPlaces,omitempty"`
}

type Excel

type Excel interface {
	// GetBackendName returns the backend used to manipulate the Excel file.
	GetBackendName() string
	// GetSheets returns a list of all worksheets in the Excel file.
	GetSheets() ([]Worksheet, error)
	// FindSheet finds a sheet by its name and returns a Worksheet.
	FindSheet(sheetName string) (Worksheet, error)
	// CreateNewSheet creates a new sheet with the specified name.
	CreateNewSheet(sheetName string) error
	// CopySheet copies a sheet from one to another.
	CopySheet(srcSheetName, destSheetName string) error
	// Save saves the Excel file.
	Save() error
}

func NewExcelizeExcel

func NewExcelizeExcel(file *excelize.File) Excel

func OpenFile

func OpenFile(absoluteFilePath string) (Excel, func(), error)

OpenFile opens an Excel file and returns an Excel interface. It first tries to open the file using OLE automation, and if that fails, it tries to using the excelize library.

type ExcelizeExcel

type ExcelizeExcel struct {
	// contains filtered or unexported fields
}

func (*ExcelizeExcel) CopySheet added in v0.7.0

func (e *ExcelizeExcel) CopySheet(srcSheetName string, destSheetName string) error

func (*ExcelizeExcel) CreateNewSheet added in v0.7.0

func (e *ExcelizeExcel) CreateNewSheet(sheetName string) error

func (*ExcelizeExcel) FindSheet

func (e *ExcelizeExcel) FindSheet(sheetName string) (Worksheet, error)

func (*ExcelizeExcel) GetBackendName added in v0.9.1

func (e *ExcelizeExcel) GetBackendName() string

func (*ExcelizeExcel) GetSheets added in v0.9.0

func (e *ExcelizeExcel) GetSheets() ([]Worksheet, error)

func (*ExcelizeExcel) Save

func (w *ExcelizeExcel) Save() error

SaveExcelize saves the Excel file to the specified path. Excelize's Save method restricts the file path length to 207 characters, but since this limitation has been relaxed in some environments, we ignore this restriction. https://github.com/qax-os/excelize/blob/v2.9.0/file.go#L71-L73

type ExcelizeFixedSizePagingStrategy

type ExcelizeFixedSizePagingStrategy struct {
	// contains filtered or unexported fields
}

ExcelizeFixedSizePagingStrategy は固定サイズでページング範囲を計算する戦略

func NewExcelizeFixedSizePagingStrategy

func NewExcelizeFixedSizePagingStrategy(pageSize int, worksheet *ExcelizeWorksheet) (*ExcelizeFixedSizePagingStrategy, error)

NewExcelizeFixedSizePagingStrategy は新しいFixedSizePagingStrategyインスタンスを生成する

func (*ExcelizeFixedSizePagingStrategy) CalculatePagingRanges

func (s *ExcelizeFixedSizePagingStrategy) CalculatePagingRanges() []string

CalculatePagingRanges は固定サイズに基づいてページング範囲のリストを生成する

type ExcelizeWorksheet

type ExcelizeWorksheet struct {
	// contains filtered or unexported fields
}

func (*ExcelizeWorksheet) AddTable added in v0.9.0

func (w *ExcelizeWorksheet) AddTable(tableRange, tableName string) error

func (*ExcelizeWorksheet) CapturePicture

func (w *ExcelizeWorksheet) CapturePicture(captureRange string) (string, error)

func (*ExcelizeWorksheet) GetCellStyle added in v0.11.0

func (w *ExcelizeWorksheet) GetCellStyle(cell string) (*CellStyle, error)

func (*ExcelizeWorksheet) GetDimention

func (w *ExcelizeWorksheet) GetDimention() (string, error)

func (*ExcelizeWorksheet) GetFormula

func (w *ExcelizeWorksheet) GetFormula(cell string) (string, error)

func (*ExcelizeWorksheet) GetPagingStrategy

func (w *ExcelizeWorksheet) GetPagingStrategy(pageSize int) (PagingStrategy, error)

func (*ExcelizeWorksheet) GetPivotTables added in v0.9.0

func (w *ExcelizeWorksheet) GetPivotTables() ([]PivotTable, error)

func (*ExcelizeWorksheet) GetTables added in v0.9.0

func (w *ExcelizeWorksheet) GetTables() ([]Table, error)

func (*ExcelizeWorksheet) GetValue

func (w *ExcelizeWorksheet) GetValue(cell string) (string, error)

func (*ExcelizeWorksheet) Name

func (w *ExcelizeWorksheet) Name() (string, error)

func (*ExcelizeWorksheet) Release added in v0.9.0

func (w *ExcelizeWorksheet) Release()

func (*ExcelizeWorksheet) SetCellStyle added in v0.12.0

func (w *ExcelizeWorksheet) SetCellStyle(cell string, style *CellStyle) error

func (*ExcelizeWorksheet) SetFormula

func (w *ExcelizeWorksheet) SetFormula(cell string, formula string) error

func (*ExcelizeWorksheet) SetValue

func (w *ExcelizeWorksheet) SetValue(cell string, value any) error

type FillPattern added in v0.12.0

type FillPattern string

FillPattern represents fill pattern constants

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"
)

func FillPatternValues added in v0.12.0

func FillPatternValues() []FillPattern

func (FillPattern) MarshalText added in v0.12.0

func (f FillPattern) MarshalText() ([]byte, error)

func (FillPattern) String added in v0.12.0

func (f FillPattern) String() string

type FillShading added in v0.12.0

type FillShading string

FillShading represents fill shading constants

const (
	FillShadingHorizontal   FillShading = "horizontal"
	FillShadingVertical     FillShading = "vertical"
	FillShadingDiagonalDown FillShading = "diagonalDown"
	FillShadingDiagonalUp   FillShading = "diagonalUp"
	FillShadingFromCenter   FillShading = "fromCenter"
	FillShadingFromCorner   FillShading = "fromCorner"
)

func FillShadingValues added in v0.12.0

func FillShadingValues() []FillShading

func (FillShading) MarshalText added in v0.12.0

func (f FillShading) MarshalText() ([]byte, error)

func (FillShading) String added in v0.12.0

func (f FillShading) String() string

type FillStyle added in v0.11.0

type FillStyle struct {
	Type    FillType     `yaml:"type,omitempty"`
	Pattern FillPattern  `yaml:"pattern,omitempty"`
	Color   []string     `yaml:"color,omitempty"`
	Shading *FillShading `yaml:"shading,omitempty"`
}

type FillType added in v0.12.0

type FillType string

FillType represents fill types for cell styles

const (
	FillTypeGradient FillType = "gradient"
	FillTypePattern  FillType = "pattern"
)

func FillTypeValues added in v0.12.0

func FillTypeValues() []FillType

func (FillType) MarshalText added in v0.12.0

func (f FillType) MarshalText() ([]byte, error)

func (FillType) String added in v0.12.0

func (f FillType) String() string

type FontStyle added in v0.11.0

type FontStyle struct {
	Bold      *bool          `yaml:"bold,omitempty"`
	Italic    *bool          `yaml:"italic,omitempty"`
	Underline *FontUnderline `yaml:"underline,omitempty"`
	Size      *int           `yaml:"size,omitempty"`
	Strike    *bool          `yaml:"strike,omitempty"`
	Color     *string        `yaml:"color,omitempty"`
	VertAlign *FontVertAlign `yaml:"vertAlign,omitempty"`
}

type FontUnderline added in v0.12.0

type FontUnderline string

FontUnderline represents underline styles for font

const (
	FontUnderlineNone             FontUnderline = "none"
	FontUnderlineSingle           FontUnderline = "single"
	FontUnderlineDouble           FontUnderline = "double"
	FontUnderlineSingleAccounting FontUnderline = "singleAccounting"
	FontUnderlineDoubleAccounting FontUnderline = "doubleAccounting"
)

func FontUnderlineValues added in v0.12.0

func FontUnderlineValues() []FontUnderline

func (FontUnderline) MarshalText added in v0.12.0

func (f FontUnderline) MarshalText() ([]byte, error)

func (FontUnderline) String added in v0.12.0

func (f FontUnderline) String() string

type FontVertAlign added in v0.12.0

type FontVertAlign string

FontVertAlign represents vertical alignment options for font styles

const (
	FontVertAlignBaseline    FontVertAlign = "baseline"
	FontVertAlignSuperscript FontVertAlign = "superscript"
	FontVertAlignSubscript   FontVertAlign = "subscript"
)

func FontVertAlignValues added in v0.12.0

func FontVertAlignValues() []FontVertAlign

func (FontVertAlign) MarshalText added in v0.12.0

func (v FontVertAlign) MarshalText() ([]byte, error)

func (FontVertAlign) String added in v0.12.0

func (v FontVertAlign) String() string

type OleExcel

type OleExcel struct {
	// contains filtered or unexported fields
}

func NewExcelOle

func NewExcelOle(absolutePath string) (*OleExcel, func(), error)

func NewExcelOleWithNewObject

func NewExcelOleWithNewObject(absolutePath string) (*OleExcel, func(), error)

func (*OleExcel) CopySheet added in v0.7.0

func (o *OleExcel) CopySheet(srcSheetName string, dstSheetName string) error

func (*OleExcel) CreateNewSheet added in v0.7.0

func (o *OleExcel) CreateNewSheet(sheetName string) error

func (*OleExcel) FindSheet

func (o *OleExcel) FindSheet(sheetName string) (Worksheet, error)

func (*OleExcel) GetBackendName added in v0.9.1

func (o *OleExcel) GetBackendName() string

func (*OleExcel) GetSheets added in v0.9.0

func (o *OleExcel) GetSheets() ([]Worksheet, error)

func (*OleExcel) Save

func (o *OleExcel) Save() error

type OleFixedSizePagingStrategy

type OleFixedSizePagingStrategy struct {
	// contains filtered or unexported fields
}

OleFixedSizePagingStrategy は Goxcel を使用した固定サイズでページング範囲を計算する戦略

func NewGoxcelFixedSizePagingStrategy

func NewGoxcelFixedSizePagingStrategy(pageSize int, worksheet *OleWorksheet) (*OleFixedSizePagingStrategy, error)

NewGoxcelFixedSizePagingStrategy は新しい GoxcelFixedSizePagingStrategy インスタンスを生成する

func (*OleFixedSizePagingStrategy) CalculatePagingRanges

func (s *OleFixedSizePagingStrategy) CalculatePagingRanges() []string

CalculatePagingRanges は固定サイズに基づいてページング範囲のリストを生成する

type OleWorksheet

type OleWorksheet struct {
	// contains filtered or unexported fields
}

func (*OleWorksheet) AddTable added in v0.9.0

func (o *OleWorksheet) AddTable(tableRange string, tableName string) error

func (*OleWorksheet) CapturePicture

func (o *OleWorksheet) CapturePicture(captureRange string) (string, error)

func (*OleWorksheet) GetCellStyle added in v0.11.0

func (o *OleWorksheet) GetCellStyle(cell string) (*CellStyle, error)

func (*OleWorksheet) GetDimention

func (o *OleWorksheet) GetDimention() (string, error)

func (*OleWorksheet) GetFormula

func (o *OleWorksheet) GetFormula(cell string) (string, error)

func (*OleWorksheet) GetPagingStrategy

func (o *OleWorksheet) GetPagingStrategy(pageSize int) (PagingStrategy, error)

func (*OleWorksheet) GetPivotTables added in v0.9.0

func (o *OleWorksheet) GetPivotTables() ([]PivotTable, error)

func (*OleWorksheet) GetTables added in v0.9.0

func (o *OleWorksheet) GetTables() ([]Table, error)

func (*OleWorksheet) GetValue

func (o *OleWorksheet) GetValue(cell string) (string, error)

func (*OleWorksheet) HPageBreaks

func (o *OleWorksheet) HPageBreaks() ([]int, error)

func (*OleWorksheet) Name

func (o *OleWorksheet) Name() (string, error)

func (*OleWorksheet) PrintArea

func (o *OleWorksheet) PrintArea() (string, error)

func (*OleWorksheet) Release added in v0.9.0

func (o *OleWorksheet) Release()

func (*OleWorksheet) SetCellStyle added in v0.12.0

func (o *OleWorksheet) SetCellStyle(cell string, style *CellStyle) error

func (*OleWorksheet) SetFormula

func (o *OleWorksheet) SetFormula(cell string, formula string) error

func (*OleWorksheet) SetValue

func (o *OleWorksheet) SetValue(cell string, value any) error

type PagingRangeService

type PagingRangeService struct {
	// contains filtered or unexported fields
}

PagingRangeService はページング処理を提供するサービス

func NewPagingRangeService

func NewPagingRangeService(strategy PagingStrategy) *PagingRangeService

NewPagingRangeService は新しいPagingRangeServiceインスタンスを生成する

func (*PagingRangeService) FilterRemainingPagingRanges

func (s *PagingRangeService) FilterRemainingPagingRanges(allRanges []string, knownRanges []string) []string

FilterRemainingPagingRanges は未読の範囲のリストを返す

func (*PagingRangeService) FindNextRange added in v0.11.0

func (s *PagingRangeService) FindNextRange(allRanges []string, currentRange string) string

FindNextRange returns the next range in the sequence after the current range

func (*PagingRangeService) GetPagingRanges

func (s *PagingRangeService) GetPagingRanges() []string

GetPagingRanges は利用可能なページング範囲のリストを返す

type PagingStrategy

type PagingStrategy interface {
	// CalculatePagingRanges は利用可能なページング範囲のリストを返す
	CalculatePagingRanges() []string
}

PagingStrategy はページング範囲の計算戦略を定義するインターフェース

func NewOlePagingStrategy

func NewOlePagingStrategy(pageSize int, worksheet *OleWorksheet) (PagingStrategy, error)

type PivotTable added in v0.9.0

type PivotTable struct {
	Name  string
	Range string
}

type PrintAreaPagingStrategy

type PrintAreaPagingStrategy struct {
	// contains filtered or unexported fields
}

PrintAreaPagingStrategy は印刷範囲とページ区切りに基づいてページング範囲を計算する戦略

func NewPrintAreaPagingStrategy

func NewPrintAreaPagingStrategy(worksheet *OleWorksheet) (*PrintAreaPagingStrategy, error)

NewPrintAreaPagingStrategy は新しいPrintAreaPagingStrategyインスタンスを生成する

func (*PrintAreaPagingStrategy) CalculatePagingRanges

func (s *PrintAreaPagingStrategy) CalculatePagingRanges() []string

CalculatePagingRanges は印刷範囲とページ区切りに基づいてページング範囲のリストを生成する

type Table added in v0.9.0

type Table struct {
	Name  string
	Range string
}

type Worksheet

type Worksheet interface {
	// Release releases the worksheet resources.
	Release()
	// Name returns the name of the worksheet.
	Name() (string, error)
	// GetTable returns a tables in this worksheet.
	GetTables() ([]Table, error)
	// GetPivotTable returns a pivot tables in this worksheet.
	GetPivotTables() ([]PivotTable, error)
	// SetValue sets a value in the specified cell.
	SetValue(cell string, value any) error
	// SetFormula sets a formula in the specified cell.
	SetFormula(cell string, formula string) error
	// GetValue gets the value from the specified cell.
	GetValue(cell string) (string, error)
	// GetFormula gets the formula from the specified cell.
	GetFormula(cell string) (string, error)
	// GetDimention gets the dimension of the worksheet.
	GetDimention() (string, error)
	// GetPagingStrategy returns the paging strategy for the worksheet.
	// The pageSize parameter is used to determine the max size of each page.
	GetPagingStrategy(pageSize int) (PagingStrategy, error)
	// CapturePicture returns base64 encoded image data of the specified range.
	CapturePicture(captureRange string) (string, error)
	// AddTable adds a table to this worksheet.
	AddTable(tableRange, tableName string) error
	// GetCellStyle gets style information for the specified cell.
	GetCellStyle(cell string) (*CellStyle, error)
	// SetCellStyle sets style for the specified cell.
	SetCellStyle(cell string, style *CellStyle) error
}

Jump to

Keyboard shortcuts

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