hoboexcel

package module
v0.0.0-...-88c9916 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2018 License: BSD-3-Clause Imports: 15 Imported by: 8

README

HoboExcel

export-import (large) excel data using constant memory usage. Use this at your own risk. At the moment no styling is supported only export/import simple tabular data. Check Out github.com/360EntSecGroup-Skylar/excelize for more feature rich library.

  • Reading Example is in testImport2
  • Writing example is in testMain.
  • Reading functionality need temporary directory
  • Concurency is not yet tested.
  • Now support export to multiple sheet(s), Example is in testMultiSheetExport

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NUM_WRITER = 2
View Source
var PARTITION_SIZE = 300 //the smaller the faster but it will produce more temporary file
View Source
var READ_TEMP_DIR = "./" //dont forget to end it with path separator
View Source
var SheetNotFoundError = errors.New("Sheet Not Found")
View Source
var TempDir = "./xl/worksheets/"

Functions

func AppXmlGenerator

func AppXmlGenerator(sheetNames []string) io.Reader

func CleanNonUtfAndControlChar

func CleanNonUtfAndControlChar(s string) string

func ContentTypeGenerator

func ContentTypeGenerator(sheetNames []string) io.Reader

func DummyAppXml

func DummyAppXml() io.Reader

func DummyContentTypes

func DummyContentTypes() io.Reader

func DummyCoreXml

func DummyCoreXml() io.Reader

func DummyRelsDotRels

func DummyRelsDotRels() io.Reader

func DummyStyleXml

func DummyStyleXml() io.Reader

func DummyThemeXml

func DummyThemeXml() io.Reader

func DummyWorkbookRels

func DummyWorkbookRels() io.Reader

func DummyWorkbookXml

func DummyWorkbookXml() io.Reader

func Export

func Export(filename string, fetcher RowFetcher)

func ExportMultisheet

func ExportMultisheet(filename string, fetcher SheetFetcher)

func ExportWorksheet

func ExportWorksheet(filename string, rows RowFetcher, SharedStrWriter *bufio.Writer, cellsCount *int)

func GetSheetId

func GetSheetId(file io.Reader, sheetTarget string) string

func PartitionSharedString

func PartitionSharedString(filename string) error

func Power

func Power(base, power int) int

func RandStringRunes

func RandStringRunes(n int) string

func SeekString

func SeekString(filename string, index int) string

func WorkbookRelGenerator

func WorkbookRelGenerator(sheetNames []string) io.Reader

func WorkbookXMLGenerator

func WorkbookXMLGenerator(sheetNames []string) io.Reader

Types

type Column

type Column struct {
	IsString bool
	// contains filtered or unexported fields
}

type Row

type Row struct {
	Collapsed    bool    `xml:"collapsed,attr,omitempty"`
	CustomFormat bool    `xml:"customFormat,attr,omitempty"`
	CustomHeight bool    `xml:"customHeight,attr,omitempty"`
	Hidden       bool    `xml:"hidden,attr,omitempty"`
	Ht           float64 `xml:"ht,attr,omitempty"`
	OutlineLevel uint8   `xml:"outlineLevel,attr,omitempty"`
	Ph           bool    `xml:"ph,attr,omitempty"`
	R            int     `xml:"r,attr,omitempty"`
	S            int     `xml:"s,attr,omitempty"`
	Spans        string  `xml:"spans,attr,omitempty"`
	ThickBot     bool    `xml:"thickBot,attr,omitempty"`
	ThickTop     bool    `xml:"thickTop,attr,omitempty"`
	C            []XlsxC `xml:"c"`
}

type RowFetcher

type RowFetcher interface {
	NextRow() []string
}

Fetch next row, if no more row exists return nil

type Sheet

type Sheet interface {
	RowFetcher
	SheetNamer
}

type SheetFetcher

type SheetFetcher interface {
	NextSheet() Sheet
	GetSheetNames() []string
}

Fetch next sheet, if no more row exists return nil

type SheetNamer

type SheetNamer interface {
	GetSheetName() string
}

type WriteWorker

type WriteWorker struct {
	Source       chan string
	CurPartition int
	Filename     string
	TargetBuffer *bufio.Writer
	TargetFile   io.Closer
	WorkerGroup  *sync.WaitGroup
}

func (*WriteWorker) Run

func (self *WriteWorker) Run()

type XlsxC

type XlsxC struct {
	R string `xml:"r,attr"`           // Cell ID, e.g. A1
	S int    `xml:"s,attr,omitempty"` // Style reference.
	// Str string `xml:"str,attr,omitempty"` // Style reference.
	T        string   `xml:"t,attr,omitempty"` // Type.
	F        *xlsxF   `xml:"f,omitempty"`      // Formula
	V        string   `xml:"v,omitempty"`      // Value
	XMLSpace xml.Attr `xml:"space,attr,omitempty"`
}

XlsxC directly maps the c element in the namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have not checked it for completeness - it does as much as I need.

type XlsxCfRule

type XlsxCfRule struct {
	AboveAverage *bool           `xml:"aboveAverage,attr"`
	Bottom       bool            `xml:"bottom,attr,omitempty"`
	DxfID        *int            `xml:"dxfId,attr"`
	EqualAverage bool            `xml:"equalAverage,attr,omitempty"`
	Operator     string          `xml:"operator,attr,omitempty"`
	Percent      bool            `xml:"percent,attr,omitempty"`
	Priority     int             `xml:"priority,attr,omitempty"`
	Rank         int             `xml:"rank,attr,omitempty"`
	StdDev       int             `xml:"stdDev,attr,omitempty"`
	StopIfTrue   bool            `xml:"stopIfTrue,attr,omitempty"`
	Text         string          `xml:"text,attr,omitempty"`
	TimePeriod   string          `xml:"timePeriod,attr,omitempty"`
	Type         string          `xml:"type,attr,omitempty"`
	Formula      []string        `xml:"formula,omitempty"`
	ColorScale   *XlsxColorScale `xml:"colorScale"`
	DataBar      *xlsxDataBar    `xml:"dataBar"`
	IconSet      *xlsxIconSet    `xml:"iconSet"`
	ExtLst       *xlsxExtLst     `xml:"extLst"`
}

XlsxCfRule (Conditional Formatting Rule) represents a description of a conditional formatting rule.

type XlsxCfvo

type XlsxCfvo struct {
	Gte    bool        `xml:"gte,attr,omitempty"`
	Type   string      `xml:"type,attr,omitempty"`
	Val    int         `xml:"val,attr"`
	ExtLst *xlsxExtLst `xml:"extLst"`
}

cfvo (Conditional Format Value Object) describes the values of the interpolation points in a gradient scale.

type XlsxCol

type XlsxCol struct {
	BestFit      bool    `xml:"bestFit,attr,omitempty"`
	Collapsed    bool    `xml:"collapsed,attr"`
	CustomWidth  bool    `xml:"customWidth,attr,omitempty"`
	Hidden       bool    `xml:"hidden,attr"`
	Max          int     `xml:"max,attr"`
	Min          int     `xml:"min,attr"`
	OutlineLevel uint8   `xml:"outlineLevel,attr,omitempty"`
	Phonetic     bool    `xml:"phonetic,attr,omitempty"`
	Style        int     `xml:"style,attr"`
	Width        float64 `xml:"width,attr"`
}

XlsxCol directly maps the col (Column Width & Formatting). Defines column width and column formatting for one or more columns of the worksheet.

type XlsxColorScale

type XlsxColorScale struct {
	Cfvo []*XlsxCfvo `xml:"cfvo"`
}

XlsxColorScale (Color Scale) describes a gradated color scale in this conditional formatting rule.

type XlsxCols

type XlsxCols struct {
	Col []XlsxCol `xml:"col"`
}

XlsxCols directly maps the cols element in the namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have not checked it for completeness - it does as much as I need.

type XlsxConditionalFormatting

type XlsxConditionalFormatting struct {
	SQRef  string        `xml:"sqref,attr,omitempty"`
	CfRule []*XlsxCfRule `xml:"cfRule"`
}

A Conditional Format is a format, such as cell shading or font color, that a spreadsheet application can automatically apply to cells if a specified condition is true. This collection expresses conditional formatting rules applied to a particular cell or range.

type XlsxRow

type XlsxRow struct {
	Collapsed    bool    `xml:"collapsed,attr,omitempty"`
	CustomFormat bool    `xml:"customFormat,attr,omitempty"`
	CustomHeight bool    `xml:"customHeight,attr,omitempty"`
	Hidden       bool    `xml:"hidden,attr,omitempty"`
	Ht           float64 `xml:"ht,attr,omitempty"`
	OutlineLevel uint8   `xml:"outlineLevel,attr,omitempty"`
	Ph           bool    `xml:"ph,attr,omitempty"`
	R            int     `xml:"r,attr,omitempty"`
	S            int     `xml:"s,attr,omitempty"`
	Spans        string  `xml:"spans,attr,omitempty"`
	ThickBot     bool    `xml:"thickBot,attr,omitempty"`
	ThickTop     bool    `xml:"thickTop,attr,omitempty"`
	C            []XlsxC `xml:"c"`
}

XlsxRow directly maps the row element. The element expresses information about an entire row of a worksheet, and contains all cell definitions for a particular row in the worksheet.

type XlsxRowFetcher

type XlsxRowFetcher struct {
	Filename        string
	ZipFile         *zip.ReadCloser
	Decoder         *xml.Decoder
	CurSheet        io.ReadCloser
	IsUsingRamCache bool //set this to true if your sharedstring is relatively small
	// contains filtered or unexported fields
}

func Import

func Import(filename string, sheetname string) (*XlsxRowFetcher, error)

func (*XlsxRowFetcher) Close

func (s *XlsxRowFetcher) Close() error

func (*XlsxRowFetcher) NextRow

func (self *XlsxRowFetcher) NextRow() []string

func (*XlsxRowFetcher) SeekString

func (r *XlsxRowFetcher) SeekString(index int) string

seek string with some caching mechanism

type XlsxSheet

type XlsxSheet struct {
	Name    string     `xml:"name,attr,omitempty"`
	SheetID string     `xml:"sheetId,attr,omitempty"`
	ID      string     `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
	State   string     `xml:"state,attr,omitempty"`
	Fetcher RowFetcher `xml:"-"`
}

XlsxSheet directly maps the sheet element from the namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have not checked it for completeness - it does as much as I need.

type XlsxSheets

type XlsxSheets struct {
	Sheet   []XlsxSheet  `xml:"sheet"`
	Fetcher SheetFetcher `xml:"-"`
}

XlsxSheets directly maps the sheets element from the namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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