示例#1
0
        /// <summary>
        /// POI 下载
        /// </summary>
        public void DownLoadPoi()
        {
            if (this.Extent == null)
            {
                Console.WriteLine(string.Format("{0}范围为空", this.City));
                return;
            }
            BaiduMap baiduMap  = new BaiduMap();
            var      dataTable = new DataTable();

            dataTable.Columns.Add("name", Type.GetType("System.String"));
            dataTable.Columns.Add("X", Type.GetType("System.String"));
            dataTable.Columns.Add("Y", Type.GetType("System.String"));
            dataTable.Columns.Add("r_addr", Type.GetType("System.String"));
            dataTable.Columns.Add("type", Type.GetType("System.String"));
            dataTable.Columns.Add("phone", Type.GetType("System.String"));
            baiduMap.downingPOIHandler += (poi, index, count) =>
            {
                DataRow row = dataTable.NewRow();
                row["name"]   = poi.name.Replace("'", " ");
                row["X"]      = poi.cx;
                row["Y"]      = poi.cy;
                row["r_addr"] = poi.address.Replace(",", "");
                row["type"]   = poi.type;
                row["phone"]  = poi.phone.Replace(",", ";");
                dataTable.Rows.Add(row);
            };
            baiduMap.downEndPOIHandler += message =>
            {
                var directory = this.GetCityDirectory();
                AsposeCellsHelper.ExportToExcel(dataTable, Path.Combine(directory, City + "_poi.xlsx"));
                dataTable.Rows.Clear();
            };
            baiduMap.getPOIByExtentKeyWords(this.Extent, string.Empty);
        }
示例#2
0
        public void TestMethod1()
        {
            DataTable dataTable = new DataTable();

            string[] columns = new string[] { "时间", "姓名", "ID" };
            dataTable.Columns.AddRange(columns.Select(m => new DataColumn(m)).ToArray());
            for (int i = 0; i < 10; i++)
            {
                DataRow row = dataTable.NewRow();
                row["时间"] = DateTime.Now;
                row["姓名"] = string.Format("第{0}个", i);
                row["ID"] = i;
                dataTable.Rows.Add(row);
            }
            string fileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Guid.NewGuid() + "测试.xls");

            AsposeCellsHelper.ExportToExcel(dataTable, fileName);
            Assert.IsTrue(System.IO.File.Exists(fileName));
        }
示例#3
0
        /// <summary>
        /// 路口数据下载
        /// </summary>
        public void DownLoadRoadCross()
        {
            var crossDataTable = new DataTable();

            crossDataTable.Columns.Add("first_name", Type.GetType("System.String"));
            crossDataTable.Columns.Add("second_name", Type.GetType("System.String"));

            crossDataTable.Columns.Add("x", Type.GetType("System.String"));
            crossDataTable.Columns.Add("y", Type.GetType("System.String"));
            crossDataTable.Columns.Add("name", Type.GetType("System.String"));

            var directory = this.GetCityDirectory();

            var path = Path.Combine(directory, this.CityPinyin + "_roadcross.xlsx");

            var road = new GaoDeRoads();

            road.roadCrossDowningHandler += (roadCross, index, count) =>
            {
                DataRow row = crossDataTable.NewRow();
                row["first_name"]  = roadCross.first_name;
                row["second_name"] = roadCross.second_name;
                row["x"]           = roadCross.wgs_x;
                row["y"]           = roadCross.wgs_y;
                row["name"]        = string.Format("{0}_{1}", roadCross.first_name, roadCross.second_name);
                crossDataTable.Rows.Add(row);
            };
            road.downOverHandler += () =>
            {
                try
                {
                    AsposeCellsHelper.ExportToExcel(crossDataTable, path);
                    crossDataTable.Rows.Clear();
                }
                catch (Exception)
                {
                    Console.WriteLine("Error" + this.City);
                }
            };
            road.downLoadRoadCrossByCityName(this.City);
        }