mirror of
https://github.com/pbnjay/grate.git
synced 2025-03-04 16:16:03 +02:00
fix XLS merged cells and ensure sentinals are correctly saved
This commit is contained in:
parent
a5375a6478
commit
e2d22a3b93
@ -40,6 +40,8 @@ func (c CellType) String() string {
|
||||
return "date"
|
||||
case HyperlinkStringCell:
|
||||
return "hyperlink"
|
||||
case StaticCell:
|
||||
return "static"
|
||||
default: // StringCell, StaticCell
|
||||
return "string"
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user