找回密码
 立即注册

QQ登录

只需一步,快速开始

hand

注册会员

11

主题

37

帖子

128

积分

注册会员

积分
128

活字格认证

hand
注册会员   /  发表于:2017-8-11 09:56  /   查看:3112  /  回复:1
Spread8.0合并单元格后并且分页格式不正确,改如何设置才能正常显示?
VB.NET代码如下
  1.    Public Sub ShowData()
  2.         Dim maxRow = 100
  3.         DetailSpread.Sheets(0).Rows.Add(0, maxRow)
  4.         Label1.Text = String.Format("第{0}页", _pageNum)
  5.         '模拟数据
  6.         Dim dt As New DataTable
  7.         dt.Columns.Add("ProjectID")
  8.         dt.Columns.Add("VoNo")
  9.         dt.Columns.Add("Description")

  10.         Dim ProjectID As Integer = 1
  11.         Dim VoNo As Integer = 1

  12.         For i As Integer = 1 To maxRow
  13.             If i Mod 5 = 0 Then
  14.                 ProjectID += 1
  15.                 VoNo += 1
  16.             End If
  17.             dt.Rows.Add("ProjectID" + Format(ProjectID, "000").ToString, "VoNo" + Format(VoNo, "000").ToString, "备注" + i.ToString)
  18.         Next
  19.         '数据绑定
  20.         DetailSpread.DataSource = dt
  21.         DetailSpread.DataBind()

  22.         For x = 0 To dt.Rows.Count - 1
  23.             Dim intCalc As Integer = 1
  24.             For y = x To dt.Rows.Count - 2
  25.                 '当ProjectID相同时
  26.                 If DetailSpread.Cells(y, 1).Text = DetailSpread.Cells(y + 1, 1).Text Then
  27.                     intCalc = intCalc + 1
  28.                 Else
  29.                     Exit For
  30.                 End If
  31.             Next
  32.             '单元格合并
  33.             CellCombination(DetailSpread.Cells(x, 0), intCalc, 1)
  34.             x = x + intCalc - 1
  35.         Next
  36.         '分页
  37.         DetailSpread.Sheets(0).PageSize = 20
  38.         DetailSpread.Sheets(0).CurrentPageIndex = _pageNum - 1
  39.     End Sub

  40.     Public Shared Sub CellCombination(ByVal cell As Cell, ByVal rowSpan As Integer, ByVal colSpan As Integer)
  41.         cell.RowSpan = rowSpan
  42.         cell.ColumnSpan = colSpan
  43.         cell.VerticalAlign = VerticalAlign.Middle
  44.     End Sub
复制代码


第一页显示正常
1.PNG
第二页显示就不正常了(红框处)
2.PNG

1 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-8-11 18:17:21
沙发
这个合并是我看您代码里的逻辑 ,这里您需要调试下,看是不是逻辑有问题或者 CellCombination 这个方法里有问题
  1.      For x = 0 To dt.Rows.Count - 1
  2.             Dim intCalc As Integer = 1
  3.             For y = x To dt.Rows.Count - 2
  4.                 '当ProjectID相同时
  5.                 If DetailSpread.Cells(y, 1).Text = DetailSpread.Cells(y + 1, 1).Text Then
  6.                     intCalc = intCalc + 1
  7.                 Else
  8.                     Exit For
  9.                 End If
  10.             Next
  11.             '单元格合并
  12.             CellCombination(DetailSpread.Cells(x, 0), intCalc, 1)
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部