From 75efccf7f976e417445f99e6eb35fcd5968a2bb0 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 18 Aug 2017 11:15:10 +0800 Subject: [PATCH 1/3] fix issue #25 --- workbook.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workbook.go b/workbook.go index e8199b7..b0aa076 100644 --- a/workbook.go +++ b/workbook.go @@ -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) } From e220ff4a46e9b4aabe4af3f2e4fc52c241d43fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E9=93=AD?= Date: Thu, 8 Mar 2018 16:45:32 +0800 Subject: [PATCH 2/3] add content about new formatter branch --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 29c1607..a23018c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Pure Golang xls library writen by [Rongshu Tech(chinese)](http://www.rongshu.tech). + +#new_formaater# branch is under test, if you have the problem about the output format, try it and tell me the problem, I will try to fix it. + + Thanks for contributions from Tamás Gulácsi, sergeilem. **English User please mailto** [Liu Ming](mailto:liuming@rongshu.tech) From d1d6f84447510f31419fb325a9f96b657b68f0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E9=93=AD?= Date: Thu, 22 Mar 2018 09:25:17 +0800 Subject: [PATCH 3/3] add OpenWithCloser function --- README.md | 11 +++++------ xls.go | 10 ++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a23018c..099dbbb 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,21 @@ Pure Golang xls library writen by [Rongshu Tech(chinese)](http://www.rongshu.tech). - -#new_formaater# branch is under test, if you have the problem about the output format, try it and tell me the problem, I will try to fix it. - - Thanks for contributions from Tamás Gulácsi, sergeilem. **English User please mailto** [Liu Ming](mailto:liuming@rongshu.tech) 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 diff --git a/xls.go b/xls.go index b425fc3..7979cb9 100644 --- a/xls.go +++ b/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 func OpenReader(reader io.ReadSeeker, charset string) (wb *WorkBook, err error) { var ole *ole2.Ole