好的,通过报表生成后的代码解决了。场景是生成418行数据区,第一页28行数据,最后一行38行数据,其余44行每页,每页footerrow占3行
Dim Book As New XLS.Book(ProjectPath & "Attachments\AAAA1.xls")
Dim fl As String = ProjectPath & "Reports\BBBBB.xls"
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
'Dim Proc As New Process '打开工作簿
'Proc.File = fl
'Proc.Start()
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
For i As Integer = 0 To 8
Dim Rg2 As MSExcel.Range
If i < 8 Then
Rg2 = Ws.Range("A" & 39+3*i+44*i) '以这个指定的单元格为基准
Else
Rg2 = Ws.Range("A" & 39+3*i+44*i-6) '以这个指定的单元格为基准
End If
For i1 As Integer = 1 To 3
Rg2.EntireRow.Insert(MSExcel.XlInsertShiftDirection.xlShiftDown)'在基准单元格上面插入一行
Next
Next
Dim Rg As MSExcel.Range
Rg = Ws.Range("456:456,457:457,458:458")
For i2 As Integer = 0 To 8
If i2 < 8 Then
Rg.Copy(Ws.Range("A" & (39+3*i2+44*i2)))
Else
Rg.Copy(Ws.Range("A" & (39+3*i2+44*i2-6)))
End If
Next
App.Visible = True
'