gocell

package module
v0.0.0-...-f752e16 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 7 Imported by: 0

README

gocell

Go Report Card GitHub license GitHub contributors GitHub go.mod Go version

gocell is a library that can translate and execute excel formulas without Microsoft Excel

This currently Work In Progress

Install

go install github.com/hyperioxx/gocell/cmd/gocell@latest

Compile an XLSX file

the following will produce a output.gcl file

gocell -build -f tests/basic.xlsx -start "Sheet1\!A1" -o ./output.gcl

Run a compiled file

gocell -run -f output.gcl

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseFormula

func ParseFormula(formula string) []efp.Token

ParseFormula parses excel formula

Types

type Cell

type Cell struct {
	Reference string
	Sheet     string
	Type      excelize.CellType
	Formula   string
	Value     string //Change this to formula struct
}

Cell representation

func NewCell

func NewCell(sheet string, ref string, formula string, _type excelize.CellType, value string) *Cell

NewCell creates a new cell

func (*Cell) String

func (c *Cell) String() string

String prints cell reference

type CellMap

type CellMap struct {
	Cells        []Cell
	Edges        map[Cell][]Cell
	StartingCell *Cell
	// contains filtered or unexported fields
}

CellMap collection of parsed Cells

func (*CellMap) AddCell

func (cm *CellMap) AddCell(c *Cell)

AddCell adds cell to cell map

func (*CellMap) AddEdge

func (cm *CellMap) AddEdge(c1, c2 *Cell)

AddEdge adds an edge to the cell map

func (*CellMap) String

func (cm *CellMap) String()

String prints cell map as string

type ExcelCompiler

type ExcelCompiler struct {
	File    *excelize.File
	CellMap *CellMap
}

ExcelCompiler compiles the excel file into golang structs

func NewExcelCompiler

func NewExcelCompiler() *ExcelCompiler

NewExcelCompiler is a constructor method that builds ExcelCompiler

func (*ExcelCompiler) BuildMap

func (ec *ExcelCompiler) BuildMap(sheet string, cellref string) *Cell

BuildMap recursivley builds cell map

func (*ExcelCompiler) Compile

func (ec *ExcelCompiler) Compile(reference string) *CellMap

Compile finds a cell reference as a starting point and compiles it recursivley

func (*ExcelCompiler) GetCell

func (ec *ExcelCompiler) GetCell(sheet string, cellref string) *Cell

GetCell returns cell

func (*ExcelCompiler) LoadFromFile

func (ec *ExcelCompiler) LoadFromFile(filepath string) error

LoadFromFile loads excel file from the filesystem

func (*ExcelCompiler) RefSplitter

func (ec *ExcelCompiler) RefSplitter(ref string) (string, string, error)

RefSplitter splits cell reference

type ExcelRunner

type ExcelRunner struct {
	CellMap *CellMap
}

ExcelRunner runs gcl files

func NewExcelRunner

func NewExcelRunner() *ExcelRunner

NewExcelRunner is a constructor method that builds ExcelRunner

func (*ExcelRunner) LoadFromFile

func (er *ExcelRunner) LoadFromFile(filePath string) error

LoadFromFile loads excel file from the filesystem

type UnknownFormula

type UnknownFormula struct{}

UnknownFormula error for when unkown formulas are trying to be created

func (*UnknownFormula) Error

func (m *UnknownFormula) Error() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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