运行代码时,我不断收到“HRESULT 异常:0x800A03EC”错误。一些论坛说“1”需要更改为“0”,反之亦然。在这一点上,我只是不知道出了什么问题,没有什么突出的。我相信我已经加载了我需要的所有参考资料,因此非常感谢任何建议/帮助。
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim objExcel As New Excel.Application
Dim bkWorkBook As Workbook
Dim shWorkSheet As Worksheet
Dim i As Integer
Dim j As Integer
objExcel = New Excel.Application
bkWorkBook = objExcel.Workbooks.Add
shWorkSheet = bkWorkBook.ActiveSheet
For i = 0 To Me.ListView1.Columns.Count
shWorkSheet.Cells(1, Chr(64 + i)) = Me.ListView1.Columns(i)
Next
For i = 1 To Me.ListView1.Items.Count
shWorkSheet.Cells(i + 2, "A") = Me.ListView1.Items(i).Text
For j = 2 To Me.ListView1.Items.Count
shWorkSheet.Cells(i + 2, Chr(64 + j)) = Me.ListView1.Items(i).SubItems(j - 1)
Next
Next
objExcel.Visible = True
End Sub
谢谢,