models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package models defines data structures for Excel document representation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDiffCSS

func GetDiffCSS() string

GetDiffCSS returns CSS styles for HTML diff display

Types

type Alignment

type Alignment struct {
	Horizontal   string `json:"horizontal,omitempty"`
	Vertical     string `json:"vertical,omitempty"`
	WrapText     bool   `json:"wrap_text,omitempty"`
	TextRotation int    `json:"text_rotation,omitempty"`
}

type ArrayFormula

type ArrayFormula struct {
	Formula string `json:"formula"`
	Range   string `json:"range"`  // The range the array formula covers
	IsCSE   bool   `json:"is_cse"` // Ctrl+Shift+Enter array formula
}

ArrayFormula represents an Excel array formula

type AutoFilter

type AutoFilter struct {
	Range   string                `json:"range"`
	Filters map[string]FilterRule `json:"filters,omitempty"`
}

AutoFilter represents AutoFilter settings for a worksheet

type Border

type Border struct {
	Left   *BorderLine `json:"left,omitempty"`
	Right  *BorderLine `json:"right,omitempty"`
	Top    *BorderLine `json:"top,omitempty"`
	Bottom *BorderLine `json:"bottom,omitempty"`
}

type BorderLine

type BorderLine struct {
	Style string `json:"style,omitempty"`
	Color string `json:"color,omitempty"`
}

type Cell

type Cell struct {
	Value          interface{}     `json:"value"`
	Formula        string          `json:"formula,omitempty"`
	FormulaR1C1    string          `json:"formula_r1c1,omitempty"`  // R1C1 reference style
	ArrayFormula   *ArrayFormula   `json:"array_formula,omitempty"` // Array formula details
	Style          *CellStyle      `json:"style,omitempty"`
	Type           CellType        `json:"type"`
	Comment        *Comment        `json:"comment,omitempty"`
	Hyperlink      string          `json:"hyperlink,omitempty"`
	DataValidation *DataValidation `json:"data_validation,omitempty"`
	RichText       []RichTextRun   `json:"rich_text,omitempty"`
}

type CellChange

type CellChange struct {
	Cell        string      `json:"cell"`
	Type        ChangeType  `json:"type"`
	OldValue    interface{} `json:"old_value,omitempty"`
	NewValue    interface{} `json:"new_value,omitempty"`
	OldFormula  string      `json:"old_formula,omitempty"`
	NewFormula  string      `json:"new_formula,omitempty"`
	Description string      `json:"description,omitempty"`
}

type CellStyle

type CellStyle struct {
	Font         *Font      `json:"font,omitempty"`
	Fill         *Fill      `json:"fill,omitempty"`
	Border       *Border    `json:"border,omitempty"`
	NumberFormat string     `json:"number_format,omitempty"`
	Alignment    *Alignment `json:"alignment,omitempty"`
}

type CellType

type CellType string
const (
	CellTypeString       CellType = "string"
	CellTypeNumber       CellType = "number"
	CellTypeBoolean      CellType = "boolean"
	CellTypeDate         CellType = "date"
	CellTypeError        CellType = "error"
	CellTypeFormula      CellType = "formula"
	CellTypeArrayFormula CellType = "array_formula"
)

type ChangeType

type ChangeType string
const (
	ChangeTypeAdd    ChangeType = "add"
	ChangeTypeModify ChangeType = "modify"
	ChangeTypeDelete ChangeType = "delete"
)

type Chart

type Chart struct {
	ID       string        `json:"id"`
	Type     string        `json:"type"` // bar, line, pie, scatter, etc.
	Title    string        `json:"title,omitempty"`
	Position ChartPosition `json:"position"`
	Series   []ChartSeries `json:"series"`
	Legend   *ChartLegend  `json:"legend,omitempty"`
	Axes     *ChartAxes    `json:"axes,omitempty"`
	Style    *ChartStyle   `json:"style,omitempty"`
}

Chart represents an Excel chart object

type ChartAxes

type ChartAxes struct {
	XAxis *ChartAxis `json:"x_axis,omitempty"`
	YAxis *ChartAxis `json:"y_axis,omitempty"`
}

type ChartAxis

type ChartAxis struct {
	Title     string   `json:"title,omitempty"`
	Min       *float64 `json:"min,omitempty"`
	Max       *float64 `json:"max,omitempty"`
	MajorUnit *float64 `json:"major_unit,omitempty"`
	MinorUnit *float64 `json:"minor_unit,omitempty"`
}

type ChartLegend

type ChartLegend struct {
	Position string `json:"position"` // top, bottom, left, right, none
	Show     bool   `json:"show"`
}

type ChartPosition

type ChartPosition struct {
	X      float64 `json:"x"`
	Y      float64 `json:"y"`
	Width  float64 `json:"width"`
	Height float64 `json:"height"`
}

type ChartSeries

type ChartSeries struct {
	Name       string `json:"name,omitempty"`
	Categories string `json:"categories,omitempty"` // Range reference like "Sheet1!A1:A10"
	Values     string `json:"values,omitempty"`     // Range reference like "Sheet1!B1:B10"
	Color      string `json:"color,omitempty"`
}

type ChartStyle

type ChartStyle struct {
	ColorScheme string `json:"color_scheme,omitempty"`
	PlotArea    string `json:"plot_area,omitempty"`
}

type Comment

type Comment struct {
	Author string `json:"author,omitempty"`
	Text   string `json:"text"`
}

type ConditionalFormat

type ConditionalFormat struct {
	Range    string      `json:"range"`
	Type     string      `json:"type"`
	Criteria string      `json:"criteria,omitempty"`
	Value    interface{} `json:"value,omitempty"`
	Minimum  interface{} `json:"minimum,omitempty"`
	Maximum  interface{} `json:"maximum,omitempty"`
	Format   *CellStyle  `json:"format,omitempty"`
}

type DataValidation

type DataValidation struct {
	Type             string `json:"type"`
	Operator         string `json:"operator,omitempty"`
	Formula1         string `json:"formula1,omitempty"`
	Formula2         string `json:"formula2,omitempty"`
	AllowBlank       bool   `json:"allow_blank,omitempty"`
	ShowInputMessage bool   `json:"show_input_message,omitempty"`
	ShowErrorMessage bool   `json:"show_error_message,omitempty"`
	ErrorTitle       string `json:"error_title,omitempty"`
	Error            string `json:"error,omitempty"`
	PromptTitle      string `json:"prompt_title,omitempty"`
	Prompt           string `json:"prompt,omitempty"`
}

type DiffSummary

type DiffSummary struct {
	TotalChanges   int `json:"total_changes"`
	AddedSheets    int `json:"added_sheets"`
	ModifiedSheets int `json:"modified_sheets"`
	DeletedSheets  int `json:"deleted_sheets"`
	CellChanges    int `json:"cell_changes"`
}

type DocumentMetadata

type DocumentMetadata struct {
	Created      time.Time `json:"created"`
	Modified     time.Time `json:"modified"`
	AppVersion   string    `json:"app_version"`
	OriginalFile string    `json:"original_file"`
	FileSize     int64     `json:"file_size"`
	Checksum     string    `json:"checksum"` // SHA256 of original
}

type DocumentProperties

type DocumentProperties struct {
	Title       string `json:"title,omitempty"`
	Subject     string `json:"subject,omitempty"`
	Author      string `json:"author,omitempty"`
	Company     string `json:"company,omitempty"`
	Keywords    string `json:"keywords,omitempty"`
	Description string `json:"description,omitempty"`
}

type ExcelDiff

type ExcelDiff struct {
	Timestamp  time.Time   `json:"timestamp"`
	Summary    DiffSummary `json:"summary"`
	SheetDiffs []SheetDiff `json:"sheet_diffs"`
}

func ComputeDiff

func ComputeDiff(oldDoc, newDoc *ExcelDocument) *ExcelDiff

ComputeDiff computes the differences between two Excel documents

func (*ExcelDiff) HasChanges

func (d *ExcelDiff) HasChanges() bool

HasChanges returns true if the diff contains any changes

func (*ExcelDiff) String

func (d *ExcelDiff) String() string

String returns a string representation of the diff

func (*ExcelDiff) ToColorizedDetailedString

func (d *ExcelDiff) ToColorizedDetailedString() string

ToColorizedDetailedString returns a detailed colorized string representation

func (*ExcelDiff) ToColorizedString

func (d *ExcelDiff) ToColorizedString() string

ToColorizedString returns a colorized string representation of the diff for terminal display

func (*ExcelDiff) ToDetailedString

func (d *ExcelDiff) ToDetailedString() string

ToDetailedString returns a detailed string representation showing all changes

func (*ExcelDiff) ToHTML

func (d *ExcelDiff) ToHTML() string

ToHTML returns an HTML representation of the diff for web display

type ExcelDocument

type ExcelDocument struct {
	Version      string             `json:"version"`
	Metadata     DocumentMetadata   `json:"metadata"`
	Sheets       []Sheet            `json:"sheets"`
	DefinedNames map[string]string  `json:"defined_names,omitempty"`
	Properties   DocumentProperties `json:"properties,omitempty"`
}

ExcelDocument represents the complete Excel file structure

type Fill

type Fill struct {
	Type    string `json:"type,omitempty"`
	Pattern string `json:"pattern,omitempty"`
	Color   string `json:"color,omitempty"`
	BgColor string `json:"bg_color,omitempty"`
}

type FilterRule

type FilterRule struct {
	Column   string   `json:"column"`
	Type     string   `json:"type"` // "list", "custom", "top10", etc.
	Criteria []string `json:"criteria,omitempty"`
	Operator string   `json:"operator,omitempty"` // "and", "or"
}

FilterRule represents a filter rule for a column

type Font

type Font struct {
	Name      string  `json:"name,omitempty"`
	Size      float64 `json:"size,omitempty"`
	Bold      bool    `json:"bold,omitempty"`
	Italic    bool    `json:"italic,omitempty"`
	Underline string  `json:"underline,omitempty"`
	Color     string  `json:"color,omitempty"`
}

type MergedCell

type MergedCell struct {
	Range string `json:"range"` // e.g., "A1:C3"
}

MergedCell represents a compact representation for merged cells

type PivotDataField

type PivotDataField struct {
	Name         string `json:"name"`
	Function     string `json:"function"` // SUM, COUNT, AVERAGE, etc.
	DisplayName  string `json:"display_name,omitempty"`
	NumberFormat string `json:"number_format,omitempty"`
}

type PivotField

type PivotField struct {
	Name     string `json:"name"`
	Position int    `json:"position"`
	Subtotal bool   `json:"subtotal,omitempty"`
}

type PivotTable

type PivotTable struct {
	ID           string              `json:"id"`
	Name         string              `json:"name"`
	SourceRange  string              `json:"source_range"` // Range reference like "Sheet1!A1:D100"
	TargetRange  string              `json:"target_range"` // Where pivot table is placed
	RowFields    []PivotField        `json:"row_fields,omitempty"`
	ColumnFields []PivotField        `json:"column_fields,omitempty"`
	DataFields   []PivotDataField    `json:"data_fields,omitempty"`
	FilterFields []PivotField        `json:"filter_fields,omitempty"`
	Settings     *PivotTableSettings `json:"settings,omitempty"`
}

PivotTable represents an Excel pivot table

type PivotTableSettings

type PivotTableSettings struct {
	ShowGrandTotals   bool `json:"show_grand_totals"`
	ShowRowHeaders    bool `json:"show_row_headers"`
	ShowColumnHeaders bool `json:"show_column_headers"`
	CompactForm       bool `json:"compact_form"`
	OutlineForm       bool `json:"outline_form"`
	TabularForm       bool `json:"tabular_form"`
}

type RichTextRun

type RichTextRun struct {
	Text string `json:"text"`
	Font *Font  `json:"font,omitempty"`
}

RichTextRun represents a segment of rich text with its own formatting

type Sheet

type Sheet struct {
	Name               string              `json:"name"`
	Index              int                 `json:"index"`
	Cells              map[string]Cell     `json:"cells"`
	MergedCells        []MergedCell        `json:"merged_cells,omitempty"`
	RowHeights         map[int]float64     `json:"row_heights,omitempty"`
	ColumnWidths       map[string]float64  `json:"column_widths,omitempty"`
	Hidden             bool                `json:"hidden"`
	Protection         *SheetProtection    `json:"protection,omitempty"`
	ConditionalFormats []ConditionalFormat `json:"conditional_formats,omitempty"`
	Charts             []Chart             `json:"charts,omitempty"`
	PivotTables        []PivotTable        `json:"pivot_tables,omitempty"`
	Tables             []Table             `json:"tables,omitempty"`
	AutoFilter         *AutoFilter         `json:"auto_filter,omitempty"`
}

type SheetDiff

type SheetDiff struct {
	SheetName string       `json:"sheet_name"`
	Action    ChangeType   `json:"action,omitempty"`
	Changes   []CellChange `json:"changes"`
}

type SheetProtection

type SheetProtection struct {
	Password            string `json:"password,omitempty"`
	EditObjects         bool   `json:"edit_objects,omitempty"`
	EditScenarios       bool   `json:"edit_scenarios,omitempty"`
	FormatCells         bool   `json:"format_cells,omitempty"`
	FormatColumns       bool   `json:"format_columns,omitempty"`
	FormatRows          bool   `json:"format_rows,omitempty"`
	InsertColumns       bool   `json:"insert_columns,omitempty"`
	InsertRows          bool   `json:"insert_rows,omitempty"`
	InsertHyperlinks    bool   `json:"insert_hyperlinks,omitempty"`
	DeleteColumns       bool   `json:"delete_columns,omitempty"`
	DeleteRows          bool   `json:"delete_rows,omitempty"`
	SelectLockedCells   bool   `json:"select_locked_cells,omitempty"`
	SelectUnlockedCells bool   `json:"select_unlocked_cells,omitempty"`
	Sort                bool   `json:"sort,omitempty"`
	AutoFilter          bool   `json:"auto_filter,omitempty"`
	PivotTables         bool   `json:"pivot_tables,omitempty"`
}

type Table

type Table struct {
	Name            string   `json:"name"`
	Range           string   `json:"range"`
	ShowHeaders     bool     `json:"show_headers"`
	ShowTotals      bool     `json:"show_totals"`
	StyleName       string   `json:"style_name,omitempty"`
	ShowFirstColumn bool     `json:"show_first_column"`
	ShowLastColumn  bool     `json:"show_last_column"`
	Columns         []string `json:"columns,omitempty"`
}

Table represents an Excel table (ListObject)

Jump to

Keyboard shortcuts

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