Use ADO.NET and setup an OLEDB Connection to the Excel spreadsheet, fill a DataTable, populate the shapefile attributes by going row-by-row thru the DataTable. Edit: here's a bit of code for setting up the ADO.NET DataTable, connecting to the spreadsheet and filling a ADO.NET DataSet. You can then begin to look at how to populate the shapefiles att's.'Excel 2007
Dim ExcelConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MyExcelSpreadsheet.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=Yes""")
Dim objCmdSelect As OleDbCommand = New OleDbCommand(expr, ExcelConnection)
Dim objAdapter1 As OleDbDataAdapter = New OleDbDataAdapter()
Dim objDT As DataTable
Dim ds As New DataSet()
Using objCmdSelect
objCmdSelect.Connection = ExcelConnection
objAdapter1.SelectCommand = objCmdSelect
objAdapter1.Fill(ds, "dtExcelData")
End Using
objDT = ds.Tables(0)
Dim ct As Integer
ct = objDT.Rows.Count 'make sure the DataTable was filled with rows
Once you have your ADO.NET DataTable object filled, you can then set the pFeatureClass to your shapefile/layer and use the IFeatureBuffer to add the attributes. Something like this (just a snippet taken from one of my applications so this is untested):Dim pFeatCur As IFeatureCursor
Dim pFeatBuf As IFeatureBuffer
pFeatBuf = pFeatureClass.CreateFeatureBuffer
pFeatCur = pFeatureClass.Insert(True)
Dim dtCol As DataColumn
Dim dtColname As String
Dim row As DataRow
For i = 0 To objDT.Rows.Count - 1
row = objDT.Rows(i)
'***add the rest of the attributes
For Each dtCol In objDT.Columns
dtColname = dtCol.ColumnName.ToString
Dim dtColType As String = dtCol.DataType.ToString
If Not IsDBNull(row.Item(dtColname)) Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = row.Item(dtColname)
Else
If dtCol.DataType.FullName.ToString = "System.Int32" Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = CInt(0)
ElseIf dtCol.DataType.FullName.ToString = "System.String" Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = CStr("NA")
ElseIf dtCol.DataType.FullName.ToString = "System.Double" Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = CDbl(0.0)
ElseIf dtCol.DataType.FullName.ToString = "System.Decimal" Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = CDec(0.0)
ElseIf dtCol.DataType.FullName.ToString = "System.DateTime" Then
pFeatBuf.Value(pFeatBuf.Fields.FindField(dtColname)) = CDate(Now())
End If
End If
Next
pFeatCur.InsertFeature(pFeatBuf)
Else
End If
Next
pFeatCur.Flush()