Spread8.0合并单元格后并且分页格式不正确,改如何设置才能正常显示?
VB.NET代码如下
- Public Sub ShowData()
- Dim maxRow = 100
- DetailSpread.Sheets(0).Rows.Add(0, maxRow)
- Label1.Text = String.Format("第{0}页", _pageNum)
- '模拟数据
- Dim dt As New DataTable
- dt.Columns.Add("ProjectID")
- dt.Columns.Add("VoNo")
- dt.Columns.Add("Description")
- Dim ProjectID As Integer = 1
- Dim VoNo As Integer = 1
- For i As Integer = 1 To maxRow
- If i Mod 5 = 0 Then
- ProjectID += 1
- VoNo += 1
- End If
- dt.Rows.Add("ProjectID" + Format(ProjectID, "000").ToString, "VoNo" + Format(VoNo, "000").ToString, "备注" + i.ToString)
- Next
- '数据绑定
- DetailSpread.DataSource = dt
- DetailSpread.DataBind()
- For x = 0 To dt.Rows.Count - 1
- Dim intCalc As Integer = 1
- For y = x To dt.Rows.Count - 2
- '当ProjectID相同时
- If DetailSpread.Cells(y, 1).Text = DetailSpread.Cells(y + 1, 1).Text Then
- intCalc = intCalc + 1
- Else
- Exit For
- End If
- Next
- '单元格合并
- CellCombination(DetailSpread.Cells(x, 0), intCalc, 1)
- x = x + intCalc - 1
- Next
- '分页
- DetailSpread.Sheets(0).PageSize = 20
- DetailSpread.Sheets(0).CurrentPageIndex = _pageNum - 1
- End Sub
- Public Shared Sub CellCombination(ByVal cell As Cell, ByVal rowSpan As Integer, ByVal colSpan As Integer)
- cell.RowSpan = rowSpan
- cell.ColumnSpan = colSpan
- cell.VerticalAlign = VerticalAlign.Middle
- End Sub
复制代码
第一页显示正常
第二页显示就不正常了(红框处)
|
|