I am importing from excel using the code below. If a row fails my validation, I want to export those rows in question to an excel file with the same name adding _fail. So myfile.xls will export to myfile_fail.xls.
I have seen comments on how to export to excel, but I wanted to just update this file and save it under a different name. If they decide to make the header a certain font, or color, I would like my new file to be the exact same format with the successful rows removed. I do not want to care about how the file is set up.
Here is the code for importing that I am using.
Function ReadDataFromExcel(ByVal excelfilename As String) As DataSet
Dim ds As New DataSet
Dim da As OleDbDataAdapter
Dim conn As OleDbConnection
conn = New OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=" & excelfilename & "; " & _
"Extended Properties=Excel 8.0;")
da = New OleDbDataAdapter("SELECT * FROM [Sheet1$]", conn)
Catch ex As Exception
If conn.State = ConnectionState.Open Then