<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Converting an Excel Spreadsheet/Access Table to a File Geodatabase. in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/converting-an-excel-spreadsheet-access-table-to-a/m-p/301171#M3533</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for looking at my issue.&amp;nbsp; I want to convert an Excel Spreadsheet into a File Geodatabase.&amp;nbsp; This has to be done in VB.Net&amp;nbsp; code, yes the database conversion tool code is available, but it is in Python.&amp;nbsp; I thought I could find a simple routine/feature that would take care of it, I have went over ESRI's site and I have not found anything so far, that does not mean it is out there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I have done is convert the Excel file to an Access Table, then take that table and try to convert it into a File Geodatabase using the IFeatureDataConverter.&amp;nbsp; I can create the File Geodaabase and then get a dataset with the field names, but no data, so I am missing something, or not interpreting something correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The base for my routine is the ConvertTable routine from this site, from what I have seen there are several samples out there built off the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub ConvertTable()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Convert an OLE DB table to a ArcSDE Geodatabase table&lt;/P&gt;&lt;P&gt;'++ Data source is an existing ODBC DSN connection to an MS Excel file&lt;/P&gt;&lt;P&gt;'++ OLE DB provider is MS OLE DB provider for ODBC Drivers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim InTable As String, OutTable As String&lt;/P&gt;&lt;P&gt;Dim ConStr As String, InProg_id As String, OutProg_id As String&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ConStr = "Provider=MSDASQL.1;Data Source=Excel_wks"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Set the In and Out WorkspaceFactory Prog_ids&lt;/P&gt;&lt;P&gt;InProg_id = "esriCore.OLEDBWorkspaceFactory.1"&lt;/P&gt;&lt;P&gt;OutProg_id = "esriCore.SDEWorkspaceFactory.1"&lt;/P&gt;&lt;P&gt;InTable = "codemog"&lt;/P&gt;&lt;P&gt;OutTable = "vtest.vtest.CODEMOG"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Create the Source Workspace&lt;/P&gt;&lt;P&gt;Dim pWorkspaceIn As IWorkspaceName&lt;/P&gt;&lt;P&gt;Set pWorkspaceIn = New WorkspaceName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Set the Source Workspace Properties&lt;/P&gt;&lt;P&gt;Dim pInPropset As IPropertySet&lt;/P&gt;&lt;P&gt;Set pInPropset = New PropertySet&lt;/P&gt;&lt;P&gt;pInPropset.SetProperty "CONNECTSTRING", ConStr&lt;/P&gt;&lt;P&gt;pWorkspaceIn.ConnectionProperties = pInPropset&lt;/P&gt;&lt;P&gt;pWorkspaceIn.WorkspaceFactoryProgID = InProg_id&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Assign input table name&lt;/P&gt;&lt;P&gt;Dim pInTableName As ITableName&lt;/P&gt;&lt;P&gt;Set pInTableName = New TableName&lt;/P&gt;&lt;P&gt;Dim pInDatasetName As IDatasetName&lt;/P&gt;&lt;P&gt;Set pInDatasetName = pInTableName&lt;/P&gt;&lt;P&gt;pInDatasetName.Name = InTable&lt;/P&gt;&lt;P&gt;Set pInDatasetName.WorkspaceName = pWorkspaceIn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Create the Destination GDB workspace.&lt;/P&gt;&lt;P&gt;Dim pOutPropSet As IPropertySet&lt;/P&gt;&lt;P&gt;Set pOutPropSet = New PropertySet&lt;/P&gt;&lt;P&gt;Dim pWorkspaceOut As IWorkspaceName&lt;/P&gt;&lt;P&gt;Set pWorkspaceOut = New WorkspaceName&lt;/P&gt;&lt;P&gt;pWorkspaceOut.WorkspaceFactoryProgID = OutProg_id &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; With pOutPropSet&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "Server", "fabio"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "Instance", "5152"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "Database", "vtest"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "user", "vtest"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "password", "go"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "version", "VTEST.EV1"&lt;/P&gt;&lt;P&gt; End With&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;pWorkspaceOut.ConnectionProperties = pOutPropSet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Create the destination table object&lt;/P&gt;&lt;P&gt;Dim pOutDatasetName As IDatasetName&lt;/P&gt;&lt;P&gt;Dim pOutTableName As ITableName&lt;/P&gt;&lt;P&gt;Set pOutTableName = New TableName&lt;/P&gt;&lt;P&gt;Set pOutDatasetName = pOutTableName&lt;/P&gt;&lt;P&gt;Set pOutDatasetName.WorkspaceName = pWorkspaceOut&lt;/P&gt;&lt;P&gt;pOutDatasetName.Name = OutTable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Open input table to get field definitions.&lt;/P&gt;&lt;P&gt;Dim pname As IName&lt;/P&gt;&lt;P&gt;Dim pTableIn As ITable&lt;/P&gt;&lt;P&gt;Set pname = pInTableName&lt;/P&gt;&lt;P&gt;Set pTableIn = pname.Open&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Validate the input table field names &lt;/P&gt;&lt;P&gt;Dim pInTableFields As IFields&lt;/P&gt;&lt;P&gt;Dim pOutTableFields As IFields&lt;/P&gt;&lt;P&gt;Dim pFieldCheck As IFieldChecker&lt;/P&gt;&lt;P&gt;Dim outEnumFieldError As esriCore.IEnumFieldError&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set pFieldCheck = New FieldChecker&lt;/P&gt;&lt;P&gt;Set pInTableFields = pTableIn.Fields&lt;/P&gt;&lt;P&gt;pFieldCheck.Validate pInTableFields, outEnumFieldError, pOutTableFields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ if there are no field errors reported, proceed to convert&lt;/P&gt;&lt;P&gt; If outEnumFieldError Is Nothing Then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Dim pOleDBToGDB As IFeatureDataConverter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Set pOleDBToGDB = New FeatureDataConverter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; pOleDBToGDB.ConvertTable pInDatasetName, Nothing, pOutDatasetName, pOutTableFields, "", 1000, 0&lt;/P&gt;&lt;P&gt; End If&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ To convert an OLE DB table to a Personal Geodatabase table&lt;/P&gt;&lt;P&gt;'++ Change the OutProg_id to "esriCore.AccessWorkspaceFactory.1"&lt;/P&gt;&lt;P&gt;'++ and set the destination workspace property "DATABASE" as follows&lt;/P&gt;&lt;P&gt;'++ pOutPropSet.SetProperty "DATABASE", "d:\data\us_states.mdb"&lt;/P&gt;&lt;P&gt;'++&lt;/P&gt;&lt;P&gt;'++ You may also wish to change the destination table name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have changed the code to where the input is an .mdb and the output is a FileGDBWorkspaceFactory, when it goes through the pOleDBToGDB.ConvertTable portion I get a dataset with the column names from the .mdb, but no data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This could be an issue, there are 123,000 rows in the .mdb table, not sure if that is an issue or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would post my code but it is Friday night at 9:30 pm and I am still running it through my mind.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So basically is there a routine out there that just does a simple input file-output file-convert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not, what am I missing by using this routine (with some modifications) to convert an .mdb to a File Geodatabase.&amp;nbsp; I am just putting the Geodatabase in a folder on my C: drive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for taking a look, Dale,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 01 Nov 2014 02:39:57 GMT</pubDate>
    <dc:creator>Dale_Shearer</dc:creator>
    <dc:date>2014-11-01T02:39:57Z</dc:date>
    <item>
      <title>Converting an Excel Spreadsheet/Access Table to a File Geodatabase.</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/converting-an-excel-spreadsheet-access-table-to-a/m-p/301171#M3533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for looking at my issue.&amp;nbsp; I want to convert an Excel Spreadsheet into a File Geodatabase.&amp;nbsp; This has to be done in VB.Net&amp;nbsp; code, yes the database conversion tool code is available, but it is in Python.&amp;nbsp; I thought I could find a simple routine/feature that would take care of it, I have went over ESRI's site and I have not found anything so far, that does not mean it is out there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I have done is convert the Excel file to an Access Table, then take that table and try to convert it into a File Geodatabase using the IFeatureDataConverter.&amp;nbsp; I can create the File Geodaabase and then get a dataset with the field names, but no data, so I am missing something, or not interpreting something correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The base for my routine is the ConvertTable routine from this site, from what I have seen there are several samples out there built off the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub ConvertTable()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Convert an OLE DB table to a ArcSDE Geodatabase table&lt;/P&gt;&lt;P&gt;'++ Data source is an existing ODBC DSN connection to an MS Excel file&lt;/P&gt;&lt;P&gt;'++ OLE DB provider is MS OLE DB provider for ODBC Drivers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim InTable As String, OutTable As String&lt;/P&gt;&lt;P&gt;Dim ConStr As String, InProg_id As String, OutProg_id As String&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ConStr = "Provider=MSDASQL.1;Data Source=Excel_wks"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Set the In and Out WorkspaceFactory Prog_ids&lt;/P&gt;&lt;P&gt;InProg_id = "esriCore.OLEDBWorkspaceFactory.1"&lt;/P&gt;&lt;P&gt;OutProg_id = "esriCore.SDEWorkspaceFactory.1"&lt;/P&gt;&lt;P&gt;InTable = "codemog"&lt;/P&gt;&lt;P&gt;OutTable = "vtest.vtest.CODEMOG"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Create the Source Workspace&lt;/P&gt;&lt;P&gt;Dim pWorkspaceIn As IWorkspaceName&lt;/P&gt;&lt;P&gt;Set pWorkspaceIn = New WorkspaceName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Set the Source Workspace Properties&lt;/P&gt;&lt;P&gt;Dim pInPropset As IPropertySet&lt;/P&gt;&lt;P&gt;Set pInPropset = New PropertySet&lt;/P&gt;&lt;P&gt;pInPropset.SetProperty "CONNECTSTRING", ConStr&lt;/P&gt;&lt;P&gt;pWorkspaceIn.ConnectionProperties = pInPropset&lt;/P&gt;&lt;P&gt;pWorkspaceIn.WorkspaceFactoryProgID = InProg_id&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Assign input table name&lt;/P&gt;&lt;P&gt;Dim pInTableName As ITableName&lt;/P&gt;&lt;P&gt;Set pInTableName = New TableName&lt;/P&gt;&lt;P&gt;Dim pInDatasetName As IDatasetName&lt;/P&gt;&lt;P&gt;Set pInDatasetName = pInTableName&lt;/P&gt;&lt;P&gt;pInDatasetName.Name = InTable&lt;/P&gt;&lt;P&gt;Set pInDatasetName.WorkspaceName = pWorkspaceIn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Create the Destination GDB workspace.&lt;/P&gt;&lt;P&gt;Dim pOutPropSet As IPropertySet&lt;/P&gt;&lt;P&gt;Set pOutPropSet = New PropertySet&lt;/P&gt;&lt;P&gt;Dim pWorkspaceOut As IWorkspaceName&lt;/P&gt;&lt;P&gt;Set pWorkspaceOut = New WorkspaceName&lt;/P&gt;&lt;P&gt;pWorkspaceOut.WorkspaceFactoryProgID = OutProg_id &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; With pOutPropSet&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "Server", "fabio"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "Instance", "5152"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "Database", "vtest"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "user", "vtest"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "password", "go"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; .SetProperty "version", "VTEST.EV1"&lt;/P&gt;&lt;P&gt; End With&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;pWorkspaceOut.ConnectionProperties = pOutPropSet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Create the destination table object&lt;/P&gt;&lt;P&gt;Dim pOutDatasetName As IDatasetName&lt;/P&gt;&lt;P&gt;Dim pOutTableName As ITableName&lt;/P&gt;&lt;P&gt;Set pOutTableName = New TableName&lt;/P&gt;&lt;P&gt;Set pOutDatasetName = pOutTableName&lt;/P&gt;&lt;P&gt;Set pOutDatasetName.WorkspaceName = pWorkspaceOut&lt;/P&gt;&lt;P&gt;pOutDatasetName.Name = OutTable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Open input table to get field definitions.&lt;/P&gt;&lt;P&gt;Dim pname As IName&lt;/P&gt;&lt;P&gt;Dim pTableIn As ITable&lt;/P&gt;&lt;P&gt;Set pname = pInTableName&lt;/P&gt;&lt;P&gt;Set pTableIn = pname.Open&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ Validate the input table field names &lt;/P&gt;&lt;P&gt;Dim pInTableFields As IFields&lt;/P&gt;&lt;P&gt;Dim pOutTableFields As IFields&lt;/P&gt;&lt;P&gt;Dim pFieldCheck As IFieldChecker&lt;/P&gt;&lt;P&gt;Dim outEnumFieldError As esriCore.IEnumFieldError&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set pFieldCheck = New FieldChecker&lt;/P&gt;&lt;P&gt;Set pInTableFields = pTableIn.Fields&lt;/P&gt;&lt;P&gt;pFieldCheck.Validate pInTableFields, outEnumFieldError, pOutTableFields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ if there are no field errors reported, proceed to convert&lt;/P&gt;&lt;P&gt; If outEnumFieldError Is Nothing Then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Dim pOleDBToGDB As IFeatureDataConverter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Set pOleDBToGDB = New FeatureDataConverter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; pOleDBToGDB.ConvertTable pInDatasetName, Nothing, pOutDatasetName, pOutTableFields, "", 1000, 0&lt;/P&gt;&lt;P&gt; End If&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'++ To convert an OLE DB table to a Personal Geodatabase table&lt;/P&gt;&lt;P&gt;'++ Change the OutProg_id to "esriCore.AccessWorkspaceFactory.1"&lt;/P&gt;&lt;P&gt;'++ and set the destination workspace property "DATABASE" as follows&lt;/P&gt;&lt;P&gt;'++ pOutPropSet.SetProperty "DATABASE", "d:\data\us_states.mdb"&lt;/P&gt;&lt;P&gt;'++&lt;/P&gt;&lt;P&gt;'++ You may also wish to change the destination table name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have changed the code to where the input is an .mdb and the output is a FileGDBWorkspaceFactory, when it goes through the pOleDBToGDB.ConvertTable portion I get a dataset with the column names from the .mdb, but no data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This could be an issue, there are 123,000 rows in the .mdb table, not sure if that is an issue or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would post my code but it is Friday night at 9:30 pm and I am still running it through my mind.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So basically is there a routine out there that just does a simple input file-output file-convert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not, what am I missing by using this routine (with some modifications) to convert an .mdb to a File Geodatabase.&amp;nbsp; I am just putting the Geodatabase in a folder on my C: drive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for taking a look, Dale,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Nov 2014 02:39:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/converting-an-excel-spreadsheet-access-table-to-a/m-p/301171#M3533</guid>
      <dc:creator>Dale_Shearer</dc:creator>
      <dc:date>2014-11-01T02:39:57Z</dc:date>
    </item>
  </channel>
</rss>

