vb.net 定义Microsoft.Office.Interop.Excel.Range的问题,请指教
Dim XlRange As Microsoft.Office.Interop.Excel.Range
Dim XL = New Microsoft.Office.Interop.Excel.Application
Dim XlList As Microsoft.Office.Interop.Excel.Range = New Microsoft.Office.Interop.Excel.Range
Dim iEachSize As Integer = DataGridView1.RowCount
Dim iColumnAccount As Integer = DataGridView1.ColumnCount
Dim NO(iEachSize, iColumnAccount) As Object
XlRange = XL.Range("A2", Chr(CInt(AscW(CChar("A"))) + DataGridView1.ColumnCount + 1) & CStr(DataGridView1.RowCount + 1))
For x = 0 To XlList.Count - 1
For y = 0 To XlList(x).Count - 1
NO(x, y) = XlList(x)(y)
Next
Next
XlRange.Value2 = NO
Dim exlApp As Excel.Application
Dim exlBook As Excel.Workbook
Dim exlSheet As Excel.Worksheet
exlApp = CreateObject("Excel.Application") '创建Excel的应用程序实例
exlBook = exlApp.Workbooks.Add '创建Excel的工作簿
'删除多余的sheet,只留一张
Dim co As Integer = exlBook.Sheets.Count
For i As Integer = 1 To co - 1
exlBook.Worksheets(1).delete()
Next
exlSheet = exlBook.Worksheets(1) '指定一张表
exlSheet.Name = _strFileName
exlApp.Visible = False
'======================================宏
' 宏由 龙觉寺 录制,时间: 2013-7-1
'exlSheet.Columns(1).ColumnWidth = 10.75
'exlSheet.Columns(2).ColumnWidth = 13.88
'设置表头
Dim oRange As Excel.Range
oRange = exlSheet.Range(exlSheet.Cells(1, 1), exlSheet.Cells(2, _DGV.ColumnCount))