Merge branch 'master' into new_formatter
This commit is contained in:
commit
ed8580ddea
@ -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.
|
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
|
# Basic Usage
|
||||||
|
|
||||||
* Use **Open** function for open file
|
* 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
|
* Follow the example in GODOC
|
||||||
|
|
||||||
|
@ -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
|
wb.sst[offset_pre] = wb.sst[offset_pre] + str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
offset_pre++
|
offset_pre++
|
||||||
err = binary.Read(buf_item, binary.LittleEndian, &size)
|
err = binary.Read(buf_item, binary.LittleEndian, &size)
|
||||||
}
|
}
|
||||||
|
10
xls.go
10
xls.go
@ -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
|
//Open xls file from reader
|
||||||
func OpenReader(reader io.ReadSeeker, charset string) (wb *WorkBook, err error) {
|
func OpenReader(reader io.ReadSeeker, charset string) (wb *WorkBook, err error) {
|
||||||
var ole *ole2.Ole
|
var ole *ole2.Ole
|
||||||
|
Loading…
Reference in New Issue
Block a user