LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Piloting excel with vb.net

Thank you, all of you, for helping me to get out of this. For those who
want to do the same thing here is the code i have made to get the type
of the excel data field :

Public Function GetDataFromXL() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
Dim plage As Excel.Range
Dim col As Integer
Dim row As Integer

plage = XLApplication.Selection()
col = plage.Columns.Count()
row = plage.Rows.Count

'Dim ii As String = XLworksheet.Type.GetTypeCode.ToString

For i As Integer = 0 To col - 1
dt.Columns.Add("Col" & i)
Next

For i As Integer = 0 To row - 1
dr = dt.NewRow
For j As Integer = 0 To col - 1
dr(j) = plage.Value2(i + 1, j + 1)
Debug.WriteLine(VarType(plage(i + 1, j + 1).Value()))
Debug.WriteLine(plage.Value2(i + 1, j + 1))
Next
dt.Rows.Add(dr)
Next
Return dt
End Function

Hope this will help someone else.

Best Regards,



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"