作者 yangfu

表格扩张修改

@@ -466,14 +466,6 @@ func (d *DataLayoutDataTable) Shrink() error { @@ -466,14 +466,6 @@ func (d *DataLayoutDataTable) Shrink() error {
466 } 466 }
467 iData++ 467 iData++
468 } 468 }
469 - //d.DataTable.Data = data  
470 - //for i := 0; i <= y; i++ {  
471 - // d.DataTable.Fields = append(d.DataTable.Fields, &domain.Field{  
472 - // Name: fmt.Sprintf("列%d", i),  
473 - // SQLName: fmt.Sprintf("col%d", i),  
474 - // SQLType: domain.String.ToString(),  
475 - // })  
476 - //}  
477 // 默认计算集第一行作为标题 469 // 默认计算集第一行作为标题
478 if len(data) >= 1 { 470 if len(data) >= 1 {
479 d.DataTable.Data = data[1:] 471 d.DataTable.Data = data[1:]
@@ -501,19 +493,28 @@ func (d *DataLayoutDataTable) Expand(cell *domain.LayoutCell, length int) error @@ -501,19 +493,28 @@ func (d *DataLayoutDataTable) Expand(cell *domain.LayoutCell, length int) error
501 if !d.CellOutRange(cell, length) { 493 if !d.CellOutRange(cell, length) {
502 return nil 494 return nil
503 } 495 }
504 - expandLength := DefaultExpandNum  
505 - if expandLength < length {  
506 - expandLength = length 496 + expand := DefaultExpandNum
  497 + if expand < length {
  498 + expand = length
507 } 499 }
508 - if d.MaxX+expandLength > MaxExpandNum+DefaultExpandNum { 500 + if d.MaxX+expand > MaxExpandNum {
509 return fmt.Errorf("布局元素超过限制 %d", MaxExpandNum) 501 return fmt.Errorf("布局元素超过限制 %d", MaxExpandNum)
510 } 502 }
511 - copyData := make([][]string, d.MaxX+length) 503 + copyData := make([][]string, d.MaxX+expand)
512 for i := range copyData { 504 for i := range copyData {
513 - copyData[i] = make([]string, d.MaxY+length) 505 + copyData[i] = make([]string, d.MaxX+expand)
  506 + }
  507 + // 拷贝已写入的数据
  508 + if d.PointEnd != nil {
  509 + for i := 0; i <= d.PointEnd.X; i++ {
  510 + for j := 0; j <= d.PointEnd.Y; j++ {
  511 + copyData[i][j] = d.DataTable.Data[i][j]
  512 + }
514 } 513 }
515 - copy(copyData, d.DataTable.Data) 514 + }
  515 + d.DataTable.Data = [][]string{}
516 d.DataTable.Data = copyData 516 d.DataTable.Data = copyData
  517 + d.AddRange(length)
517 return nil 518 return nil
518 } 519 }
519 520