作者 yangfu

表格扩张修改

... ... @@ -466,14 +466,6 @@ func (d *DataLayoutDataTable) Shrink() error {
}
iData++
}
//d.DataTable.Data = data
//for i := 0; i <= y; i++ {
// d.DataTable.Fields = append(d.DataTable.Fields, &domain.Field{
// Name: fmt.Sprintf("列%d", i),
// SQLName: fmt.Sprintf("col%d", i),
// SQLType: domain.String.ToString(),
// })
//}
// 默认计算集第一行作为标题
if len(data) >= 1 {
d.DataTable.Data = data[1:]
... ... @@ -501,19 +493,28 @@ func (d *DataLayoutDataTable) Expand(cell *domain.LayoutCell, length int) error
if !d.CellOutRange(cell, length) {
return nil
}
expandLength := DefaultExpandNum
if expandLength < length {
expandLength = length
expand := DefaultExpandNum
if expand < length {
expand = length
}
if d.MaxX+expandLength > MaxExpandNum+DefaultExpandNum {
if d.MaxX+expand > MaxExpandNum {
return fmt.Errorf("布局元素超过限制 %d", MaxExpandNum)
}
copyData := make([][]string, d.MaxX+length)
copyData := make([][]string, d.MaxX+expand)
for i := range copyData {
copyData[i] = make([]string, d.MaxY+length)
copyData[i] = make([]string, d.MaxX+expand)
}
// 拷贝已写入的数据
if d.PointEnd != nil {
for i := 0; i <= d.PointEnd.X; i++ {
for j := 0; j <= d.PointEnd.Y; j++ {
copyData[i][j] = d.DataTable.Data[i][j]
}
}
copy(copyData, d.DataTable.Data)
}
d.DataTable.Data = [][]string{}
d.DataTable.Data = copyData
d.AddRange(length)
return nil
}
... ...