Data Table To Excel
Data Table To Excel
Imports System.IO
Imports System.Text
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports Excel = Microsoft.Office.Interop.Excel
'Ajouter l'Utilsateur ASPNET au groupe Administrateurs(pour evité Accés refusé) : click droit poste travail -> Gérer ->
Utilisateurs et groupes locaux -> Groupes ...
'colvisible : les colonnes visibles
If IsNothing(colvisible) Then
colvisible = New Integer() {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20}
End If
If visibleHeader Then
startRow = 2
For j As Integer = 0 To dt.Columns.Count - 1
If colvisible.IndexOf(colvisible, j) <> -1 Then
xlWorkSheet.Cells(1, colindex).value = dt.Columns(j).ColumnName
colindex += 1
End If
Next
End If
-1-
C:\DataTableToExcel.vb jeudi 14 avril 2011 14:36
filename)
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
Return filename
Catch ex As Exception
Return ""
End Try
End Function
-2-