xlsx

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

xlsx/csv列提取器

  1. 根据指定标题列表提取列字段
  2. 标题行前可以有空行
  3. 正确转化日期

使用方法


import (
	"github.com/rosbit/xlsx-extractor"
	"os"
	"fmt"
)

func main() {
	// --- reading xlsx book sheet ----
	book, err := os.Open("somebook.xlsx")
	if err != nil {
		// error
		return
	}
	defer book.Close()

	rows, err := xlsx.XlsxRows(book, "Sheet1", []string{"title1", "title2", "title3"})
	if err != nil {
		// error
	}
	for row := range rows {
		fmt.Printf("%#v\n", row)
	}

	// --- reading csv ----
	fpCsv, err := os.Open("somename.csv")
	if err != nil {
		// error
	}
	defer fpCsv.Close()
	lines, err := xlsx.CsvRows(fpCsv, []string{"title1", "title2"})
	if err != nil {
		// error
	}
	for line := range lines {
		fmt.Printf("%#v\n", line)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CsvRows

func CsvRows(book io.Reader, titles []string) (<-chan []string, error)

func CsvRowsWithTitles

func CsvRowsWithTitles(book io.Reader, titles []string) ([]string, <-chan []string, error)

func Rows

func Rows(book io.Reader, sheet string, titles []string, o ...Option) (<-chan []string, error)

func RowsWithTitles

func RowsWithTitles(book io.Reader, sheet string, titles []string, o ...Option) ([]string, <-chan []string, error)

func XlsRows added in v1.1.0

func XlsRows(book io.ReadSeeker, charset, sheet string, titles []string, o ...Option) (<-chan []string, error)

func XlsRowsWithTitles added in v1.1.0

func XlsRowsWithTitles(book io.ReadSeeker, charset, sheet string, titles []string, o ...Option) ([]string, <-chan []string, error)

Types

type Option added in v1.1.0

type Option func(*Options)

func SetDateFields added in v1.1.0

func SetDateFields(dateFields []string) Option

func SkipLines added in v1.1.0

func SkipLines(linesBeforeTitles, linesAfterTitles int) Option

type Options added in v1.1.0

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

Jump to

Keyboard shortcuts

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