20
0
This commit is contained in:
Liu Ming 2016-09-30 11:46:51 +08:00
parent 76d16d4682
commit cc2ab32c3f
3 changed files with 8 additions and 6 deletions

4
row.go
View File

@ -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
}

View File

@ -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]
}

View File

@ -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
}