资源简介

ArcEngine二次开发,读取特定格式的Excel(示例文件已给出)中的坐标信息,生成点图层并输出对应的Shape文件。从Excel生成Shape图层。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.GlobeCore;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.GeocodingTools;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.GeoDatabaseExtensions;
using ESRI.ArcGIS.DataSourcesGDB;


namespace ArcEngine
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {

        }

        private DataSet importExcelToDataSet(string FilePath)
        {

            string strConn;

            strConn = “Provider=Microsoft.Jet.OLEDB.4.0;“ + “Data Source=“ + FilePath + “;Extended Properties=Excel 8.0;“;

            OleDbConnection conn = new OleDbConnection(strConn);

            OleDbDataAdapter myCommand = new OleDbDataAdapter(“SELECT * FROM [Sheet1$]“ strConn);

            DataSet myDataSet = new DataSet();

            try
            {

                myCommand.Fill(myDataSet);

            }

            catch (Exception ex)
            {

               

            }

            return myDataSet;

        }
        private void ProcessDataSet(DataSet dataSet)
        {
            
        }

        private void 打开ToolStripMenuItem_Click(object sender EventArgs e)
        {

            OpenFileDialog openFileDialog=new OpenFileDialog();
            openFileDialog.InitialDirectory=“D:\\“;//注意这里写路径时要用c:\\而不是c:\
            openFileDialog.Filter=“excl文件|*.xls|所有文件|*.*“;
            openFileDialog.RestoreDirectory=true;
            openFileDialog.FilterIndex=1;
            if (openFileDialog.ShowDialog()==DialogResult.OK)
            {
                string fName=openFileDialog.FileName;
                DataTable myT = ExcelToDataTable(fName “sheet1“);
                String mystr = myT.Rows[0][0].ToString();

                int count = 0;
                ilayer ly = CreateShapeFile(fName);

                if (ly == null)
                    return;
                for (int i = 1; i < myT.Rows.Count; ++i)
                {
                    //string temp = myT.Rows[i][“ID“].ToString();
                    string name = myT.Rows[i][1].ToString();
                    string address = myT.Rows[i][2].ToString();
                    double jingdu = Convert.ToDouble(myT.Rows[i][3]);

                    double weidu = Convert.ToDouble(myT.Rows[i][4]);

                    if (addPoint(ly jingdu weidu name address))
                    {
                        count++;
                    }

                   

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-09-26 23:05  excel生成点图层\
     目录           0  2014-03-16 18:23  excel生成点图层\ArcEngine\
     目录           0  2014-03-16 18:23  excel生成点图层\ArcEngine\ArcEngine\
     文件       23721  2014-03-16 17:02  excel生成点图层\ArcEngine\ArcEngine\ArcEngine.csproj
     文件        9018  2014-03-16 18:08  excel生成点图层\ArcEngine\ArcEngine\Form1.Designer.cs
     文件       10514  2014-03-16 18:08  excel生成点图层\ArcEngine\ArcEngine\Form1.cs
     文件       11925  2014-03-16 18:08  excel生成点图层\ArcEngine\ArcEngine\Form1.resx
     文件         490  2014-03-16 14:51  excel生成点图层\ArcEngine\ArcEngine\Program.cs
     目录           0  2014-03-16 18:23  excel生成点图层\ArcEngine\ArcEngine\Properties\
     文件        1368  2014-03-16 14:51  excel生成点图层\ArcEngine\ArcEngine\Properties\AssemblyInfo.cs
     文件        2868  2014-03-16 14:51  excel生成点图层\ArcEngine\ArcEngine\Properties\Resources.Designer.cs
     文件        5612  2014-03-16 14:51  excel生成点图层\ArcEngine\ArcEngine\Properties\Resources.resx
     文件        1094  2014-03-16 14:51  excel生成点图层\ArcEngine\ArcEngine\Properties\Settings.Designer.cs
     文件         249  2014-03-16 14:51  excel生成点图层\ArcEngine\ArcEngine\Properties\Settings.settings
     目录           0  2014-03-16 18:23  excel生成点图层\ArcEngine\ArcEngine\bin\
     目录           0  2014-03-16 18:23  excel生成点图层\ArcEngine\ArcEngine\bin\Debug\
     文件       22528  2014-03-16 18:09  excel生成点图层\ArcEngine\ArcEngine\bin\Debug\ArcEngine.exe
     文件       32256  2014-03-16 18:09  excel生成点图层\ArcEngine\ArcEngine\bin\Debug\ArcEngine.pdb
     文件       11600  2014-03-16 18:22  excel生成点图层\ArcEngine\ArcEngine\bin\Debug\ArcEngine.vshost.exe
     文件         490  2010-03-17 22:39  excel生成点图层\ArcEngine\ArcEngine\bin\Debug\ArcEngine.vshost.exe.manifest
     文件      765440  2010-05-19 14:25  excel生成点图层\ArcEngine\ArcEngine\bin\Debug\ESRI.ArcGIS.Desktop.AddIns.dll
     目录           0  2014-03-16 18:23  excel生成点图层\ArcEngine\ArcEngine\obj\
     目录           0  2014-03-16 18:23  excel生成点图层\ArcEngine\ArcEngine\obj\x86\
     目录           0  2014-03-16 18:23  excel生成点图层\ArcEngine\ArcEngine\obj\x86\Debug\
     文件        4112  2014-03-16 18:09  excel生成点图层\ArcEngine\ArcEngine\obj\x86\Debug\ArcEngine.Form1.resources
     文件         180  2014-03-16 17:02  excel生成点图层\ArcEngine\ArcEngine\obj\x86\Debug\ArcEngine.Properties.Resources.resources
     文件        1122  2014-03-16 18:22  excel生成点图层\ArcEngine\ArcEngine\obj\x86\Debug\ArcEngine.csproj.FileListAbsolute.txt
     文件       22528  2014-03-16 18:09  excel生成点图层\ArcEngine\ArcEngine\obj\x86\Debug\ArcEngine.exe
     文件       32256  2014-03-16 18:09  excel生成点图层\ArcEngine\ArcEngine\obj\x86\Debug\ArcEngine.pdb
     文件        2164  2014-03-16 14:51  excel生成点图层\ArcEngine\ArcEngine\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
     文件       15632  2014-03-16 18:09  excel生成点图层\ArcEngine\ArcEngine\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
............此处省略6个文件信息

评论

共有 条评论