Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/dsp163/go-xlsx-parser

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/dsp163/go-xlsx-parser

  • v0.1.1
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-xlsx-parser

SAX like streaming xlsx parser

SYNOPSIS

doc := xlsx.Open("your.xlsx")
parser := &MyParser{}
doc.ParseSheet("Sheet 1", parser)
type MyParser struct{}
func (p *MyParser) ReadRow(rowCount int, columns []interface{}) {
     // write your parser here!
}

Example

package main

import (
	"fmt"
	"strings"
	"time"

	"github.com/acidlemon/go-xlsx-parser/xlsx"
)

func main() {
	doc := xlsx.Open("xlsx/test.xlsx")
	parser := &MyParser{}

	doc.ParseSheet("シート1", parser)
}

type MyParser struct{}

// see xlsx/parser.go
func (p *MyParser) ReadRow(rowCount int, columns []interface{}) {
	fmt.Printf("Line %d:\n", rowCount)
	data := []string{}
	for _, value := range columns {
		switch v := value.(type) {
		case string:
			data = append(data, `"`+v+`"`)

		case int64:
			data = append(data, fmt.Sprintf("%d", v))

		case float64:
			data = append(data, fmt.Sprintf("%f", v))

		case time.Time:
			data = append(data, v.Format(`"2006-01-02 15:04:05"`))
		}
	}

	fmt.Println(" ", strings.Join(data, `,`))
}

Enjoy!

FAQs

Package last updated on 15 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc