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

Hi,
i would like to know how i can get the type of an excel field. I have
tried to use the vartype method but it's always returning "object"
which refers to the field and not to the type of data which is in the
field...

Hope someone will be able to help me.

Regards

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Piloting excel with vb.net

Can someone help me please ? I am really stuck and i don't know how to
get out of this...

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Piloting excel with vb.net

Check the type of the *contents*, not the cell itself (which will always be "object")

--
Tim Williams
Palo Alto, CA


"VoTiger" wrote in message oups.com...
Can someone help me please ? I am really stuck and i don't know how to
get out of this...



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Piloting excel with vb.net

Make sure you pass the Value property of the cell, not just a
reference to the cell itself.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"VoTiger" wrote in message
oups.com...
Hi,
i would like to know how i can get the type of an excel field.
I have
tried to use the vartype method but it's always returning
"object"
which refers to the field and not to the type of data which is
in the
field...

Hope someone will be able to help me.

Regards



  #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,

Reply
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 02:35 AM.

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

About Us

"It's about Microsoft Excel"