excel

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 5 Imported by: 0

README

excel 基于go-ole

可以操作xls文件,必须先安装Microsoft office excel,2010以前的版本最多只能操作65535行。

为了便于操作,任何函数不会因抛出错误而退出程序,但是任何错误的操作都可能返回nil。

如:Excel.NewWorkBook(),是返回workbook对象,错误时会返回的workbook将会是nil

安装

go get -u -v github.com/jinzhongmin/excel

例子

package main

import (
	"github.com/jinzhongmin/excel"
)

func main() {
	excel.CoInit() //必须先执行
	Excel := excel.NewExcel()
	Const := excel.NewConst()
	Excel.Visible(true)

	workbook := Excel.NewWorkBook()
	sheet1 := workbook.Sheet(0)
	sheet1.Cell(1, 1).SetValue("Hello excel")
	sheet1.Cell(1, 1).GetFont().SetColor("FF00FF")
	byName := workbook.Sheet(sheet1.GetName())
	byName.Cell(1, 2).SetValue("get sheet by name")

	workbook.SaveAs("excel.xlsx", Const.FILEFORMATxlWorkbookDefault)

	Excel.Close()
	excel.CoUnInit() //必须执行
}

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoInit

func CoInit()

func CoUnInit

func CoUnInit()

func LetterToNum

func LetterToNum(cr string) (int, int)

LetterToNum ..

func NumToLetter

func NumToLetter(col, row int) string

NumToLetter ..

Types

type Cell

type Cell struct {
	// contains filtered or unexported fields
}

Cell ..

func (*Cell) GetFont

func (c *Cell) GetFont() *Font

GetFont ..

func (*Cell) GetValue

func (c *Cell) GetValue() string

GetValue ..

func (*Cell) Range

func (c *Cell) Range() *Range

Range ..

func (*Cell) SetValue

func (c *Cell) SetValue(val string)

SetValue ..

type Col

type Col struct {
	// contains filtered or unexported fields
}

Col ..

func (*Col) Cell

func (c *Col) Cell(index int) *Cell

Cell ..

func (*Col) Len

func (c *Col) Len() int

Len ..

func (*Col) Range

func (c *Col) Range() *Range

Range ..

type Const

type Const struct {
	FILEFORMATxlAddIn                       int
	FILEFORMATxlAddIn8                      int
	FILEFORMATxlCSV                         int
	FILEFORMATxlCSVMac                      int
	FILEFORMATxlCSVMSDOS                    int
	FILEFORMATxlCSVWindows                  int
	FILEFORMATxlCurrentPlatformText         int
	FILEFORMATxlDBF2                        int
	FILEFORMATxlDBF3                        int
	FILEFORMATxlDBF4                        int
	FILEFORMATxlDIF                         int
	FILEFORMATxlExcel12                     int
	FILEFORMATxlExcel2                      int
	FILEFORMATxlExcel2FarEast               int
	FILEFORMATxlExcel3                      int
	FILEFORMATxlExcel4                      int
	FILEFORMATxlExcel4Workbook              int
	FILEFORMATxlExcel5                      int
	FILEFORMATxlExcel7                      int
	FILEFORMATxlExcel8                      int
	FILEFORMATxlExcel9795                   int
	FILEFORMATxlHTML                        int
	FILEFORMATxlIntlAddIn                   int
	FILEFORMATxlIntlMacro                   int
	FILEFORMATxlOpenDocumentSpreadsheet     int
	FILEFORMATxlOpenXMLAddIn                int
	FILEFORMATxlOpenXMLStrictWorkbook       int
	FILEFORMATxlOpenXMLTemplate             int
	FILEFORMATxlOpenXMLTemplateMacroEnabled int
	FILEFORMATxlOpenXMLWorkbook             int
	FILEFORMATxlOpenXMLWorkbookMacroEnabled int
	FILEFORMATxlSYLK                        int
	FILEFORMATxlTemplate                    int
	FILEFORMATxlTemplate8                   int
	FILEFORMATxlTextMac                     int
	FILEFORMATxlTextMSDOS                   int
	FILEFORMATxlTextPrinter                 int
	FILEFORMATxlTextWindows                 int
	FILEFORMATxlUnicodeText                 int
	FILEFORMATxlWebArchive                  int
	FILEFORMATxlWJ2WD1                      int
	FILEFORMATxlWJ3                         int
	FILEFORMATxlWJ3FJ3                      int
	FILEFORMATxlWK1                         int
	FILEFORMATxlWK1ALL                      int
	FILEFORMATxlWK1FMT                      int
	FILEFORMATxlWK3                         int
	FILEFORMATxlWK3FM3                      int
	FILEFORMATxlWK4                         int
	FILEFORMATxlWKS                         int
	FILEFORMATxlWorkbookDefault             int
	FILEFORMATxlWorkbookNormal              int
	FILEFORMATxlWorks2FarEast               int
	FILEFORMATxlWQ1                         int
	FILEFORMATxlXMLSpreadsheet              int
}

Const ..

func NewConst

func NewConst() *Const

NewConst ..

type Excel

type Excel struct {
	// contains filtered or unexported fields
}

Excel ..

func NewExcel

func NewExcel() (*Excel, error)

NewExcel ..

func (*Excel) Alert

func (e *Excel) Alert(v bool)

Alert ..

func (*Excel) Close

func (e *Excel) Close()

Close ..

func (*Excel) NewWorkBook

func (e *Excel) NewWorkBook() *Workbook

NewWorkBook ..

func (*Excel) OpenWorkBook

func (e *Excel) OpenWorkBook(file string) *Workbook

OpenWorkBook ..

func (*Excel) Visible

func (e *Excel) Visible(v bool)

Visible ..

func (*Excel) WorkBooks

func (e *Excel) WorkBooks() []*Workbook

WorkBooks ..

type Font

type Font struct {
	// contains filtered or unexported fields
}

Font ..

func (*Font) GetColor

func (f *Font) GetColor() string

GetColor ..

func (*Font) GetName

func (f *Font) GetName() string

GetName ..

func (*Font) GetSize

func (f *Font) GetSize() float64

GetSize ..

func (*Font) SetColor

func (f *Font) SetColor(hex string)

SetColor ..

func (*Font) SetName

func (f *Font) SetName(name string)

SetName ..

func (*Font) SetSize

func (f *Font) SetSize(size float64)

SetSize ..

type Range

type Range struct {
	// contains filtered or unexported fields
}

Range ..

func (*Range) Cell

func (r *Range) Cell(col int, row int) *Cell

Cell ..

func (*Range) ClearFormats

func (r *Range) ClearFormats()

ClearFormats ..

func (*Range) Col

func (r *Range) Col(num int) *Col

Col ..

func (*Range) ColRange

func (r *Range) ColRange(num int) *Range

ColRange ..

func (*Range) Copy

func (r *Range) Copy(dest *Range)

Copy ..

func (*Range) Range

func (r *Range) Range(x, y, w, h int) *Range

Range ..

func (*Range) Row

func (r *Range) Row(num int) *Row

Row ..

func (*Range) RowRange

func (r *Range) RowRange(num int) *Range

RowRange ..

type Row

type Row struct {
	// contains filtered or unexported fields
}

Row ..

func (*Row) Cell

func (r *Row) Cell(index int) *Cell

Cell ..

func (*Row) Len

func (r *Row) Len() int

Len ..

func (*Row) Range

func (r *Row) Range() *Range

Range ..

type Sheet

type Sheet struct {
	// contains filtered or unexported fields
}

Sheet ..

func (*Sheet) Cell

func (s *Sheet) Cell(col int, row int) *Cell

Cell ..

func (*Sheet) Col

func (s *Sheet) Col(c int) *Col

Col ..

func (*Sheet) GetName

func (s *Sheet) GetName() string

GetName ..

func (*Sheet) Row

func (s *Sheet) Row(r int) *Row

Row ..

func (*Sheet) SetName

func (s *Sheet) SetName(name string)

SetName ..

func (*Sheet) UsedRange

func (s *Sheet) UsedRange() *Range

UsedRange ..

type Workbook

type Workbook struct {
	// contains filtered or unexported fields
}

Workbook ..

func (*Workbook) AppendSheet

func (wb *Workbook) AppendSheet() *Sheet

AppendSheet ..

func (*Workbook) Close

func (wb *Workbook) Close()

Close ..

func (*Workbook) Save

func (wb *Workbook) Save()

Save ..

func (*Workbook) SaveAs

func (wb *Workbook) SaveAs(name string, format int)

SaveAs ..

func (*Workbook) Sheet

func (wb *Workbook) Sheet(index interface{}) *Sheet

Sheet ..

func (*Workbook) Sheets

func (wb *Workbook) Sheets() []*Sheet

Sheets ..

Jump to

Keyboard shortcuts

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