fix:add parse merge cell
This commit is contained in:
parent
4a6cf26307
commit
03cbf97453
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.idea/
|
||||
go.sum
|
22
col.go
22
col.go
@ -11,7 +11,7 @@ import (
|
||||
yymmdd "github.com/extrame/goyymmdd"
|
||||
)
|
||||
|
||||
//content type
|
||||
// content type
|
||||
type contentHandler interface {
|
||||
String(*WorkBook) []string
|
||||
FirstCol() uint16
|
||||
@ -64,7 +64,7 @@ func (xf *XfRk) String(wb *WorkBook) string {
|
||||
strings.Contains(formatterLower, "d.y") ||
|
||||
strings.Contains(formatterLower, "h:") ||
|
||||
strings.Contains(formatterLower, "д.г") {
|
||||
//If format contains # or .00 then this is a number
|
||||
// If format contains # or .00 then this is a number
|
||||
return xf.Rk.String()
|
||||
} else {
|
||||
i, f, isFloat := xf.Rk.number()
|
||||
@ -82,7 +82,7 @@ func (xf *XfRk) String(wb *WorkBook) string {
|
||||
f = float64(i)
|
||||
}
|
||||
t := timeFromExcelTime(f, wb.dateMode == 1)
|
||||
return t.Format(time.RFC3339) //TODO it should be international
|
||||
return t.Format(time.RFC3339) // TODO it should be international
|
||||
}
|
||||
}
|
||||
return xf.Rk.String()
|
||||
@ -184,8 +184,8 @@ func (c *FormulaStringCol) String(wb *WorkBook) []string {
|
||||
return []string{c.RenderedValue}
|
||||
}
|
||||
|
||||
//str, err = wb.get_string(buf_item, size)
|
||||
//wb.sst[offset_pre] = wb.sst[offset_pre] + str
|
||||
// str, err = wb.get_string(buf_item, size)
|
||||
// wb.sst[offset_pre] = wb.sst[offset_pre] + str
|
||||
|
||||
type FormulaCol struct {
|
||||
Header struct {
|
||||
@ -238,3 +238,15 @@ type BlankCol struct {
|
||||
func (c *BlankCol) String(wb *WorkBook) []string {
|
||||
return []string{""}
|
||||
}
|
||||
|
||||
type MergeCells struct {
|
||||
Count uint16
|
||||
Refs []Ref8
|
||||
}
|
||||
|
||||
type Ref8 struct {
|
||||
RwFirst uint16
|
||||
RwLast uint16
|
||||
ColFirst uint16
|
||||
ColLast uint16
|
||||
}
|
||||
|
17
worksheet.go
17
worksheet.go
@ -5,6 +5,7 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"unicode/utf16"
|
||||
)
|
||||
|
||||
@ -35,6 +36,8 @@ type WorkSheet struct {
|
||||
MaxRow uint16
|
||||
parsed bool
|
||||
rightToLeft bool
|
||||
// NOTICE: get all merge cell
|
||||
mergeCells *MergeCells
|
||||
}
|
||||
|
||||
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)
|
||||
buf = bytes.NewReader(bts)
|
||||
switch b.Id {
|
||||
// case 0x0E5: //MERGEDCELLS
|
||||
// ws.mergedCells(buf)
|
||||
case 0x0E5: // MERGEDCELLS
|
||||
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
|
||||
var sheetOptions, firstVisibleRow, firstVisibleColumn uint16
|
||||
binary.Read(buf, binary.LittleEndian, &sheetOptions)
|
||||
|
Loading…
Reference in New Issue
Block a user