请问:这样引用整行,为什么会出错?
Dim Book As New XLS.Book(ProjectPath & "Attachments\数据表.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Dim fl As String = ProjectPath & "Reports\数据表.xls"
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.UsedRange ' 已使用范围
rg.Formula = rg.Formula
Rg.WrapText = True
'Rg.EntireColumn.AutoFit '自动调整列宽
Rg.EntireRow.AutoFit '自动调整行高
''MessageBox.Show(RG.Rows.Count)
For I As Integer = 1 To RG.Rows.Count
Dim 行号 As String = """" & I & """"
RG = Ws.Rows(行号) ' 这样引用整行,为什么会出错?
RG = WS.Rows(I) ' 这样引用整行,为什么会出错?
''Rg.RowHeight = Rg.RowHeight + 12 ' 在原有行高的基础上加上12
Next
Ws.PageSetup.PrintTitleRows = Ws.Rows("$1:$2").Address
Wb.Save
App.QUIT