S
scorpion53061
Additional information: Exception from HRESULT: 0x800A03EC.
This code produced this error. I am pretty sure I got this to run a while
back and I was wondering if you all see anything I am doing wrong.....or do
you have a suggestion for a better way.......I do know this method is quite
slow.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim WSheet As New Excel.Worksheet
Dim colindex As Integer
Dim Excel As New Excel.Application
Dim rowindex As Integer
Try
OleDbDataAdapter1.Fill(DataSet11.ITEMS)
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
With WSheet
Dim col As DataColumn
colindex = 1
Dim rowon As Integer = 1
For Each col In DataSet11.Tables(0).Columns
'colindex += 1
Excel.Cells(rowon, colindex) = col.ColumnName.ToString
colindex = colindex + 1
Next col
Dim row As DataRow
colindex = 1
rowindex = 2
For Each row In DataSet11.Tables(0).Rows
For Each col In DataSet11.Tables(0).Columns
'colindex += 1
.Cells(rowindex, colindex).Value =
row(col.ColumnName).ToString()
rowindex = rowindex + 1
colindex = colindex + 1
Next col
Next row
Try
'Saving .xls file with Test.xls name
WSheet.SaveAs("C:\TEST.XLS")
Catch
End Try
'setting up caption that "File Created"
Me.Text = "File Created"
'closing down workbook
EXL.Workbooks.Close()
End With
End Sub
This code produced this error. I am pretty sure I got this to run a while
back and I was wondering if you all see anything I am doing wrong.....or do
you have a suggestion for a better way.......I do know this method is quite
slow.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim WSheet As New Excel.Worksheet
Dim colindex As Integer
Dim Excel As New Excel.Application
Dim rowindex As Integer
Try
OleDbDataAdapter1.Fill(DataSet11.ITEMS)
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
With WSheet
Dim col As DataColumn
colindex = 1
Dim rowon As Integer = 1
For Each col In DataSet11.Tables(0).Columns
'colindex += 1
Excel.Cells(rowon, colindex) = col.ColumnName.ToString
colindex = colindex + 1
Next col
Dim row As DataRow
colindex = 1
rowindex = 2
For Each row In DataSet11.Tables(0).Rows
For Each col In DataSet11.Tables(0).Columns
'colindex += 1
.Cells(rowindex, colindex).Value =
row(col.ColumnName).ToString()
rowindex = rowindex + 1
colindex = colindex + 1
Next col
Next row
Try
'Saving .xls file with Test.xls name
WSheet.SaveAs("C:\TEST.XLS")
Catch
End Try
'setting up caption that "File Created"
Me.Text = "File Created"
'closing down workbook
EXL.Workbooks.Close()
End With
End Sub