From cc2ab32c3fdcc79936ff00b9d2a66a9332a60aed Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 30 Sep 2016 11:46:51 +0800 Subject: [PATCH] fix issue #12 --- row.go | 4 ++-- workbook.go | 4 +++- worksheet.go | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/row.go b/row.go index fc8b766..d41dae4 100644 --- a/row.go +++ b/row.go @@ -1,6 +1,6 @@ package xls -type RowInfo struct { +type rowInfo struct { Index uint16 Fcell uint16 Lcell uint16 @@ -11,6 +11,6 @@ type RowInfo struct { } type Row struct { - info *RowInfo + info *rowInfo Cols map[uint16]contentHandler } diff --git a/workbook.go b/workbook.go index c5bdb70..027c87a 100644 --- a/workbook.go +++ b/workbook.go @@ -115,10 +115,11 @@ func (wb *WorkBook) parseBof(buf io.ReadSeeker, b *bof, pre *bof, offset_pre int var size uint16 var i = 0 for ; i < int(info.Count); i++ { - if err := binary.Read(buf_item, binary.LittleEndian, &size); err == nil || err == io.EOF { + if err := binary.Read(buf_item, binary.LittleEndian, &size); err == nil { var str string str, err = wb.get_string(buf_item, size) wb.sst[i] = wb.sst[i] + str + if err == io.EOF { break } @@ -284,6 +285,7 @@ func (w *WorkBook) ReadAllCells(max int) (res [][]string) { data = append(data, make([]string, col.LastCol()-uint16(len(data))+1)...) } str := col.String(w) + for i := uint16(0); i < col.LastCol()-col.FirstCol()+1; i++ { data[col.FirstCol()+i] = str[i] } diff --git a/worksheet.go b/worksheet.go index 35af1e7..80ce728 100644 --- a/worksheet.go +++ b/worksheet.go @@ -49,7 +49,7 @@ func (w *WorkSheet) parseBof(buf io.ReadSeeker, b *bof, pre *bof) *bof { // case 0x0E5: //MERGEDCELLS // ws.mergedCells(buf) case 0x208: //ROW - r := new(RowInfo) + r := new(rowInfo) binary.Read(buf, binary.LittleEndian, r) w.addRow(r) case 0x0BD: //MULRK @@ -182,14 +182,14 @@ func (w *WorkSheet) addContent(row_num uint16, ch contentHandler) { var row *Row var ok bool if row, ok = w.Rows[row_num]; !ok { - info := new(RowInfo) + info := new(rowInfo) info.Index = row_num row = w.addRow(info) } row.Cols[ch.FirstCol()] = ch } -func (w *WorkSheet) addRow(info *RowInfo) (row *Row) { +func (w *WorkSheet) addRow(info *rowInfo) (row *Row) { if info.Index > w.MaxRow { w.MaxRow = info.Index }