1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlSheet As New Microsoft.Office.Interop.Excel.Worksheet
Dim xlSheet2 As New Microsoft.Office.Interop.Excel.Worksheet
xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
xlBook = CType(xlApp.Workbooks.(1), Microsoft.Office.Interop.Excel.Workbook)
xlSheet = CType(xlBook.Worksheets.Add(), Microsoft.Office.Interop.Excel.Worksheet)
xlSheet2 = CType(xlBook.Worksheets(2), Microsoft.Office.Interop.Excel.Worksheet)
Dim Ds = New DataSet()
Sql = "SELECT * From tatata"
da = New OracleDataAdapter(Sql, Con)
Ds = New DataSet()
da.Fill(Ds, "tab")
'ici c'est la methode qui remple la feuille
xlSheet = ExportTableToExcel(Ds.Tables("tab"))
xlSheet2 = ExportTableToExcel(Ds.Tables("tab"))
'ce code marche, j'ai bien mes données dans la feuille
xlSheet.Application.ActiveWorkbook.SaveAs(dossier + "/" + "/tatata.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel7)
xlSheet2.Application.ActiveWorkbook.SaveAs(dossier + "/" + "/tatata2.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel7)
'par contre celui la nom, le worbook est bien enregistré, mais les feuille n'ont pas changé
xlBook.SaveAs(dossier + "/tatata.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel7) |
Partager