ods

package module
v0.0.0-...-b6811de Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2015 License: MIT Imports: 10 Imported by: 1

README

ODS decoder for Go

This package only convers my own needs. It decodes a spreadsheet into a [][]string nothing more than that. It does handle table cells with extra formating and stylning in the sense that it just strips them away.

Opening a ODF/ODS file is decoupled from the actual decoding so you can inject what ever middle reader you need (ex. different character encoding).

package main

import (
	"fmt"
	"log"
	"strings"

	"github.com/ksev/ods"
)

func main() {
	reader, err := ods.OpenReader("file.ods")
	if err != nil {
		log.Fatal(err)
	}
	defer reader.Close()

	table, err := ods.Decode(reader)
	if err != nil {
		log.Fatal(err)
	}

	for _, row := range table {
		fmt.Println(strings.Join(row, "|"))
	}
}

Documentation

Overview

Read Open Document Format spreadsheets

Index

Constants

View Source
const (
	MIMETYPE = "application/vnd.oasis.opendocument.spreadsheet"
)

Variables

This section is empty.

Functions

func Decode

func Decode(reader io.Reader) ([][]string, error)

func NewReader

func NewReader(rdr io.Reader) (io.Reader, error)

NewReader takes an exsisting reader and reads the spreadsheet out of it. It's important to note that this will exhaust the underlying Reader and is NOT streaming. This happens because ODF/ODS files are ZIP files and they require random read access.

func OpenReader

func OpenReader(path string) (io.ReadCloser, error)

Opens a reader for the content part of ODF. Takes a string path to specified file. Some simple sanity checks are made to make sure the file is a ODS spreadsheet.

Types

This section is empty.

Jump to

Keyboard shortcuts

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