21
0

1) boundsheet field order fixed

2) `WorkSheet.Visibility` implemented (and typed constants)
3) `WorkSheet.Selected` implemented - most of cases require to parse _current_ sheet, not the first one
4) `WorkSheet.rightToLeft` property for future use (not implemented cause no RtL files present)
This commit is contained in:
Ivan 2019-03-17 20:55:41 +03:00
parent 539786826c
commit 10ff2752d9
2 changed files with 27 additions and 8 deletions

View File

@ -246,7 +246,7 @@ func (w *WorkBook) get_string(buf io.ReadSeeker, size uint16) (res string, err e
func (w *WorkBook) addSheet(sheet *boundsheet, buf io.ReadSeeker) {
name, _ := w.get_string(buf, uint16(sheet.Name))
w.sheets = append(w.sheets, &WorkSheet{bs: sheet, Name: name, wb: w})
w.sheets = append(w.sheets, &WorkSheet{bs: sheet, Name: name, wb: w, Visibility: TWorkSheetVisibility(sheet.Visible)})
}
//reading a sheet from the compress file to memory, you should call this before you try to get anything from sheet

View File

@ -7,22 +7,33 @@ import (
"unicode/utf16"
)
type TWorkSheetVisibility byte
const (
WorkSheetVisible TWorkSheetVisibility = 0
WorkSheetHidden TWorkSheetVisibility = 1
WorkSheetVeryHidden TWorkSheetVisibility = 2
)
type boundsheet struct {
Filepos uint32
Visible TWorkSheetVisibility
Type byte
Visible byte
Name byte
}
//WorkSheet in one WorkBook
type WorkSheet struct {
bs *boundsheet
wb *WorkBook
Name string
rows map[uint16]*Row
bs *boundsheet
wb *WorkBook
Name string
Selected bool
Visibility TWorkSheetVisibility
rows map[uint16]*Row
//NOTICE: this is the max row number of the sheet, so it should be count -1
MaxRow uint16
parsed bool
MaxRow uint16
parsed bool
rightToLeft bool
}
func (w *WorkSheet) Row(i int) *Row {
@ -56,6 +67,14 @@ func (w *WorkSheet) parseBof(buf io.ReadSeeker, b *bof, pre *bof) *bof {
switch b.Id {
// case 0x0E5: //MERGEDCELLS
// ws.mergedCells(buf)
case 0x23E: // WINDOW2
var sheetOptions, firstVisibleRow, firstVisibleColumn uint16
binary.Read(buf, binary.LittleEndian, &sheetOptions)
binary.Read(buf, binary.LittleEndian, &firstVisibleRow) // not valuable
binary.Read(buf, binary.LittleEndian, &firstVisibleColumn) // not valuable
buf.Seek(int64(b.Size)-2*3, 1)
w.rightToLeft = (sheetOptions & 0x40) != 0
w.Selected = (sheetOptions & 0x400) != 0
case 0x208: //ROW
r := new(rowInfo)
binary.Read(buf, binary.LittleEndian, r)