diff --git a/commonxl/cell.go b/commonxl/cell.go index c6f8efc..9b1c5b2 100644 --- a/commonxl/cell.go +++ b/commonxl/cell.go @@ -40,6 +40,8 @@ func (c CellType) String() string { return "date" case HyperlinkStringCell: return "hyperlink" + case StaticCell: + return "static" default: // StringCell, StaticCell return "string" } diff --git a/commonxl/sheet.go b/commonxl/sheet.go index 467fef4..a165334 100644 --- a/commonxl/sheet.go +++ b/commonxl/sheet.go @@ -67,6 +67,14 @@ func (s *Sheet) Put(row, col int, value interface{}, fmtNum uint16) { s.Resize(s.NumRows, s.NumCols) } + if spec, ok := value.(string); ok { + if spec == grate.EndRowMerged || spec == grate.EndColumnMerged || spec == grate.ContinueRowMerged || spec == grate.ContinueColumnMerged { + s.Rows[row][col] = NewCell(value) + s.Rows[row][col][1] = StaticCell + return + } + } + ct, ok := s.Formatter.getCellType(fmtNum) if !ok || fmtNum == 0 { s.Rows[row][col] = NewCell(value) @@ -125,6 +133,10 @@ func (s *Sheet) Strings() []string { res[i] = "" continue } + if cell.Type() == StaticCell { + res[i] = cell.Value().(string) + continue + } val := cell.Value() fs, ok := s.Formatter.Apply(cell.FormatNo(), val) if !ok { diff --git a/xls/sheets.go b/xls/sheets.go index 652917b..ce2218a 100644 --- a/xls/sheets.go +++ b/xls/sheets.go @@ -386,10 +386,10 @@ func (b *WorkBook) parseSheet(s *boundSheet, ss int) (*commonxl.Sheet, error) { cmcs := binary.LittleEndian.Uint16(r.Data[:2]) raw := r.Data[2:] for i := 0; i < int(cmcs); i++ { - firstRow := binary.LittleEndian.Uint16(r.Data[:2]) - lastRow := binary.LittleEndian.Uint16(r.Data[2:4]) - firstCol := binary.LittleEndian.Uint16(r.Data[4:6]) - lastCol := binary.LittleEndian.Uint16(r.Data[6:]) + firstRow := binary.LittleEndian.Uint16(raw[:2]) + lastRow := binary.LittleEndian.Uint16(raw[2:4]) + firstCol := binary.LittleEndian.Uint16(raw[4:6]) + lastCol := binary.LittleEndian.Uint16(raw[6:]) raw = raw[8:] if lastRow == 0xFFFF { // placeholder value indicate "last"