spreadsheet

package
v0.0.0-...-040724e Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: BSD-3-Clause, GPL-2.0, BSD-3-Clause, + 1 more Imports: 7 Imported by: 3

Documentation

Overview

Package spreadsheet for interacting with spreadsheets

Package spreadsheet for interacting with spreadsheets

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func A1FormatToRowColumn

func A1FormatToRowColumn(a1 string) (row, column int, err error)

A1FormatToRowColumn parses an A1 style excel cell coordinate into ints for row and column for use by plotinum library note that 1 is subtracted from the column number in accordance with the go convention of counting from 0

func AutoFormat

func AutoFormat(xlsxfile *xlsx.File)

AutoFormat applies basic default formatting to a spreadsheet. Column widths will be estimated and set to the estimated width for each column of a sheet. A thick border will be added to the base of the first row of the each sheet.

func Column

func Column(sheet *xlsx.Sheet, column int) (cells []*xlsx.Cell, err error)

Column returns all cells for a column. The index of the column should be used.

func ConvertMinMaxtoArray

func ConvertMinMaxtoArray(minmax []string) (array []string, err error)

ConvertMinMaxtoArray converts a pair of cell positions an array of all entries between the pair will be returned (e.g. a1:a12 or a1:e1)

func GetDataFromCell

func GetDataFromCell(sheet *xlsx.Sheet, cellPositionInA1Format string) (cell *xlsx.Cell, err error)

GetDataFromCell returns the cell contents at the specified cell position in an xlsx sheet. The cellPositionInA1Formatshould be specified according to standard xslx nomenclature. i.e. a letter corresponding to column followed by a number corresponding to row (starting from 1). i.e. the first cell would be A1. An error is returned if no value at the requested well position is found.

func GetDataFromCells

func GetDataFromCells(sheet *xlsx.Sheet, cellcoords []string) (cells []*xlsx.Cell, err error)

GetDataFromCells returns the cell contents at the specified cell positions in an xlsx sheet. The cellcoords be specified according to standard xslx nomenclature. i.e. a letter corresponding to column followed by a number corresponding to row (starting from 1). i.e. the first cell would be A1. An error is returned if no value at the requested well position is found.

func GetDataFromRowCol

func GetDataFromRowCol(sheet *xlsx.Sheet, col int, row int) (cell *xlsx.Cell, err error)

GetDataFromRowCol returns the cell contents at the specified row and column number in an xlsx sheet. An error is returned if the column aor row number specified is beyond the range available in the sheet. Counting starts from zero. i.e. the cell at the first row and first column would be called by cell, err := GetDataFromRowCol(sheet, 0,0)

func OpenXLSX

func OpenXLSX(xlsx wtype.File) (file *xlsx.File, err error)

OpenXLSX opens an xlsx file and returns the xlsx.File data structure.

func OpenXLSXBinary

func OpenXLSXBinary(bytes []byte) (file *xlsx.File, err error)

OpenXLSXBinary parses the contents of an xlsx file into the xlsx.File data structure.

func OpenXLSXFromFileName

func OpenXLSXFromFileName(filename string) (file *xlsx.File, err error)

OpenXLSXFromFileName will open an xlsx file from a filename.

func Row

func Row(sheet *xlsx.Sheet, rowNumber int) (cells []*xlsx.Cell, err error)

Row returns all cells for a row. The index of the row should be used.

func Sheet

func Sheet(file *xlsx.File, sheetnum int) (sheet *xlsx.Sheet, err error)

Sheet returns the xlsx.Sheet in the xlsx file according to the sheet number. An error is returned if an invalid sheet number is specified. The sheet object looks like this:

type Sheet struct {
	Name        string
	File        *File
	Rows        []*Row
	Cols        []*Col
	MaxRow      int
	MaxCol      int
	Hidden      bool
	Selected    bool
	SheetViews  []SheetView
	SheetFormat SheetFormat
	AutoFilter  *AutoFilter
}

func SheetToCSV

func SheetToCSV(sheet *xlsx.Sheet) (records [][]string)

SheetToCSV returns a matrix of string values for the contents of each cell in the sheet.

func ToHeaderDataMap

func ToHeaderDataMap(sheet *xlsx.Sheet, useHeaderRow int) (headerdatamap map[string][]*xlsx.Cell, err error)

ToHeaderDataMap returns a map of all column headers with corresponding cells. useHeaderRow corresponds to the row to use for the headers. If this is the first row, it should be set to 0.

Types

This section is empty.

Jump to

Keyboard shortcuts

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