20
0

Merge branch 'master' into new_formatter

This commit is contained in:
刘铭 2018-03-22 09:26:49 +08:00
commit ed8580ddea
3 changed files with 19 additions and 2 deletions

View File

@ -10,12 +10,15 @@ Thanks for contributions from Tamás Gulácsi, sergeilem.
This is a xls library writen in pure Golang. Almostly it is translated from the libxls library in c.
It has just the reading function without the format.
The master brunch has just the reading function without the format.
***new_formater** branch is for better format for date and number ,but just under test, you can try it in development environment. If you have some problem about the output format, tell me the problem, I will try to fix it.*
# Basic Usage
* Use **Open** function for open file
* Use **OpenReader** function for open xls from a reader
* Use **OpenWithCloser** function for open file and use the return value closer for close file
* Use **OpenReader** function for open xls from a reader, you should close related file in your own code
* Follow the example in GODOC

View File

@ -101,6 +101,10 @@ func (wb *WorkBook) parseBof(buf io.ReadSeeker, b *bof, pre *bof, offset_pre int
wb.sst[offset_pre] = wb.sst[offset_pre] + str
}
if err == io.EOF {
break
}
offset_pre++
err = binary.Read(buf_item, binary.LittleEndian, &size)
}

10
xls.go
View File

@ -16,6 +16,16 @@ func Open(file string, charset string) (*WorkBook, error) {
}
}
//Open one xls file and return the closer
func OpenWithCloser(file string, charset string) (*WorkBook, io.Closer, error) {
if fi, err := os.Open(file); err == nil {
wb, err := OpenReader(fi, charset)
return wb, fi, err
} else {
return nil, nil, err
}
}
//Open xls file from reader
func OpenReader(reader io.ReadSeeker, charset string) (wb *WorkBook, err error) {
var ole *ole2.Ole