Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( NoCurrentSheetError = errors.New("No Current Sheet") WrongNumberOfRowsError = errors.New("Invalid number of cells passed to WriteRow. All calls to WriteRow on the same sheet must have the same number of cells.") AlreadyOnLastSheetError = errors.New("NextSheet() called, but already on last sheet.") UnsupportedCellType = errors.New("Unsupported cell type") UnknownCellType = errors.New("Unknown cell type") )
var BuiltExcelStreamBuilderError = errors.New("StreamFileBuilder has already been built, functions may no longer be used")
Functions ¶
This section is empty.
Types ¶
type StreamFile ¶
type StreamFile struct {
// contains filtered or unexported fields
}
func (*StreamFile) Close ¶
func (sf *StreamFile) Close() error
Close closes the Stream File. Any sheets that have not yet been written to will have an empty sheet created for them.
func (*StreamFile) NextSheet ¶
func (sf *StreamFile) NextSheet() error
NextSheet will switch to the next sheet. Sheets are selected in the same order they were added. Once you leave a sheet, you cannot return to it.
func (*StreamFile) WriteRow ¶
func (sf *StreamFile) WriteRow(cells []string) error
WriteRow will write a row of cells to the current sheet. Every call to WriteRow on the same sheet must contain the same number of cells as the header provided when the sheet was created or an error will be returned. This function will always trigger a flush on success. Currently the only supported data type is string data.
type StreamFileBuilder ¶
type StreamFileBuilder struct {
// contains filtered or unexported fields
}
func NewStreamFileBuilder ¶
func NewStreamFileBuilder(writer io.Writer) *StreamFileBuilder
NewExcelBuilder creates an StreamFileBuilder that will write to the the provided io.writer
func NewStreamFileBuilderForPath ¶
func NewStreamFileBuilderForPath(path string) (*StreamFileBuilder, error)
NewExcelBuilderForFile takes the name of an XLSX file and returns a builder for it. The file will be created if it does not exist, or truncated if it does.
func (*StreamFileBuilder) AddSheet ¶
func (sb *StreamFileBuilder) AddSheet(name string, headers []string) error
AddSheet will add sheets with the given name with the provided headers. The headers cannot be edited later, and all rows written to the sheet must contain the same number of cells as the header. Sheet names must be unique, or an error will be thrown.
func (*StreamFileBuilder) Build ¶
func (sb *StreamFileBuilder) Build() (*StreamFile, error)
Build begins streaming the XLSX file to the io, by writing all the Excel metadata. It creates a StreamFile struct that can be used to write the rows to the sheets.