Skip to content

Package xls2csv is a Golang package which converts XLS file to CSV records. It's based on libxls and xls2csv.

License

Notifications You must be signed in to change notification settings

northbright/xls2csv-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xls2csv-go

Build Status Go Report Card GoDoc

Package xls2csv is a Golang package which converts XLS file to CSV records. It's based on libxls and xls2csv.

Install xls2csv package

  • xls2csv requires libxls to be installed.

    • Install libxls

      wget https://github.com/libxls/libxls/releases/download/v1.6.2/libxls-1.6.2.tar.gz
      tar -xzvf libxls-1.6.2.tar.gz
      cd libxls-1.6.2
      ./configure
      make
      sudo make install
      
    • Add libxls lib path to LD_LIBRARY_PATH

      • Create a new /etc/ld.so.conf.d/libxls.conf

            sudo vi /etc/ld.so.conf.d/libxls.conf
        
            // Add path of libxls to this file
            /usr/local/libxls/lib
        
      • Update LD_LIBRARY_PATH

          sudo ldconfig
          // Check libxlsreader.so
          sudo ldconfig -p | grep libxls
        
  • Install xls2csv package

      CGO_CFLAGS=-I/usr/local/libxls/include CGO_LDFLAGS="-L/usr/local/libxls/lib -l xlsreader" go get github.com/northbright/xls2csv-go/xls2csv
    

Usage

package main

import (
    "fmt"

    "github.com/northbright/xls2csv-go/xls2csv"
)

func main() {
    var err error

    f := "/home/xx/my.xls"
    sheetId := 0
    records := [][]string{}

    // Call XLS2CSV() to convert XLS and get all records.
    if records, err = xls2csv.XLS2CSV(f, sheetId); err != nil {
        fmt.Printf("err: %v\n", err)
        return
    }

    fmt.Printf("records: %v\n", records)
}

Build and Test Your App

  • Do not forget to add CGO_CFLAGS=-I/usr/local/libxls/include CGO_LDFLAGS="-L/usr/local/libxls/lib -l xlsreader" before go build or go test

      CGO_CFLAGS=-I/usr/local/libxls/include CGO_LDFLAGS="-L/usr/local/libxls/lib -l xlsreader" go build
    

Documentation

License

About

Package xls2csv is a Golang package which converts XLS file to CSV records. It's based on libxls and xls2csv.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published