Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _ & "Data Source=" & workbookFileName & ";Extended Properties=Excel 8.0" 'Create an OleDb connection object Dim con As New System.Data.OleDb.OleDbConnection(connectionString) 'enumerate through the rows of the data table and insert into the appropriate 'Excel worksheet based on the breakCount value. Dim breakCount As Int32 = 65535 Dim sheetIndex As Int32 = 1 Dim recordIndex As Int32 = 0 Dim sheetName As String = "Sheet" & sheetIndex Dim insertStatement As System.Text.StringBuilder Dim command As System.Data.OleDb.OleDbCommand con.Open() For Each row As DataRow In data.Rows recordIndex += 1 If recordIndex = breakCount Then sheetIndex += 1 sheetName = "Sheet" & sheetIndex.ToString End If 'Write the Insert Statement for the current record insertStatement = New System.Text.StringBuilder insertStatement.Append("INSERT INTO [" & sheetName & "$] VALUES (") For Each col As DataColumn In data.Columns insertStatement.Append("'" & row(col.ColumnName).ToString.Replace("'", "''") & "', ") Next command = New System.Data.OleDb.OleDbCommand Try With command .Connection = con .CommandText = insertStatement.ToString.Substring(0, insertStatement.ToString.LastIndexOf(Char.Parse(","))) & ")" .CommandType = CommandType.Text .ExecuteNonQuery() End With Catch ex As System.Data.OleDb.OleDbException MessageBox.Show(ex.Message) End Try Next con.Dispose() command.Dispose()