20
0

fix:add parse merge cell

This commit is contained in:
吴俊杰 2020-09-11 14:25:20 +08:00
parent 4a6cf26307
commit 03cbf97453
3 changed files with 34 additions and 7 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea/
go.sum

12
col.go
View File

@ -238,3 +238,15 @@ type BlankCol struct {
func (c *BlankCol) String(wb *WorkBook) []string { func (c *BlankCol) String(wb *WorkBook) []string {
return []string{""} return []string{""}
} }
type MergeCells struct {
Count uint16
Refs []Ref8
}
type Ref8 struct {
RwFirst uint16
RwLast uint16
ColFirst uint16
ColLast uint16
}

View File

@ -5,6 +5,7 @@ import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"io" "io"
"log"
"unicode/utf16" "unicode/utf16"
) )
@ -35,6 +36,8 @@ type WorkSheet struct {
MaxRow uint16 MaxRow uint16
parsed bool parsed bool
rightToLeft bool rightToLeft bool
// NOTICE: get all merge cell
mergeCells *MergeCells
} }
func (w *WorkSheet) Row(i int) *Row { func (w *WorkSheet) Row(i int) *Row {
@ -70,8 +73,18 @@ func (w *WorkSheet) parseBof(buf io.ReadSeeker, b *bof, pre *bof, col_pre interf
binary.Read(buf, binary.LittleEndian, bts) binary.Read(buf, binary.LittleEndian, bts)
buf = bytes.NewReader(bts) buf = bytes.NewReader(bts)
switch b.Id { switch b.Id {
// case 0x0E5: //MERGEDCELLS case 0x0E5: // MERGEDCELLS
// ws.mergedCells(buf) mergeCells := new(MergeCells)
err := binary.Read(buf, binary.LittleEndian, &mergeCells.Count)
size := (b.Size - 2) / 8
mergeCells.Refs = make([]Ref8, size)
for i := uint16(0); i < size; i++ {
binary.Read(buf, binary.LittleEndian, &mergeCells.Refs[i])
}
if err != nil {
log.Fatal(err)
}
w.mergeCells = mergeCells
case 0x23E: // WINDOW2 case 0x23E: // WINDOW2
var sheetOptions, firstVisibleRow, firstVisibleColumn uint16 var sheetOptions, firstVisibleRow, firstVisibleColumn uint16
binary.Read(buf, binary.LittleEndian, &sheetOptions) binary.Read(buf, binary.LittleEndian, &sheetOptions)