APP下载

第二次全国地名普查地名登记表批量导入的实现*

2016-10-27高仕华杨海关代进文

地矿测绘 2016年3期
关键词:建库登记表批量

陈 平,高仕华,杨海关,代进文

(1.云南省测绘工程院,云南 昆明 650034; 2.云南省测绘产品检测站,云南 昆明 650034)



第二次全国地名普查地名登记表批量导入的实现*

陈平1,高仕华1,杨海关2,代进文1

(1.云南省测绘工程院,云南 昆明650034; 2.云南省测绘产品检测站,云南 昆明650034)

随着第二次全国地名普查的深入开展,地名登记表已经基本填写完毕,如何高效、快速地将地名登记表录入到地名普查数据管理系统中显得非常重要,文章介绍了基于C#编程把地名登记表批量导入到地名属性表,然后将地名属性表一次性录入到地名普查数据管理系统的方法,极大地提高了工作效率。

地名普查;地名登记表;批量导入;C#

0 引言

云南省第二次全国地名普查从2014年7月1日开始,到2018年6月30日结束,分4个阶段实施(动员部署阶段、全面普查阶段、检查验收上报阶段、普查成果开发利用阶段)。

地名普查的任务是查清地名基本情况,对有地无名的有地名作用的地理实体进行命名,对不规范地名进行标准化处理,设置标准规范的地名标志,建立、完善各级国家地名和区划数据库(国家地名数据库)。

地名是基础地理信息。地名普查是一项公益性、基础性的国情调查。开展地名普查,查清并掌握地名基本情况,提高地名标准化水平,为社会提供全面准确的地名信息,有利于维护国家主权和领土完整、巩固国防建设,有利于经济社会协调发展,有利于社会交流交往、方便人民群众生产生活,对提高政府管理水平和公共服务具有重要意义[1-4]。

云南省第二次全国地名普查使用的普查软件为江苏速度信息科技有限公司开发的云南省第二次全国地名普查数据建库与管理软件[1]。该软件提供了地名属性表(Excel)数据导入功能,能够实现地名信息批量导入。但在全面普查阶段中,填写的地名登记表都是单张的Word表格,如表1所示。为此,本文介绍了基于C#编程批量实现所有地名登记表(Word)批量导入地名属性表(Excel)的方法,从而实现地名信息的批量导入。

1 地名登记表批量导入地名属性表

1.1程序实现方法

程序通过打开文件夹中的每一张地名登记表,读取地名登记表中的类别名称,判断类别名称为第二次全国地名普查内容与指标中的一级、二级、三级类别名称中具体的哪一个类别,然后再读取地名登记表(Word)中每一个单元格的信息,根据对应关系写入到地名属性表(Excel)相应的单元格中,将地名登记表内的属性导入到相应的地名属性表中。地名属性表包括陆地水系、陆地地形、行政区域、群众自治组织、非行政区域、居民点、交通运输设施、水利水电通信设施、纪念地旅游景点、建筑物、单位共11个大类的属性表格。

程序打开、读取、判断每一张地名登记表,并导入到相应的地名属性表后,关闭该地名登记表和相应的地名属性表,然后循环操作下一张地名登记表和相应的地名属性表,直到选择的文件夹下的所有地名登记表都导入完毕。该方法能够快速释放内存,不会因为地名登记表数量太多而导致电脑内存不足崩溃死机,程序运行效率较高。

表1地名登记表样表

Tab.1Place names registration form’s sample

1.2程序实现主要代码

程序实现的主要代码如下:

string path = @textBox1.Text;

string path1 = @textBox3.Text;

string[] fileList = Directory.GetFileSystemEntries(path1);

int m = 2;

{

foreach(stringfileinfileList)

{

if(File.Exists(file))

{

objectunknow=Type.Missing;

msWord.Applicationwordapp=newmsWord

.Application();

wordapp.Visible=false;

try

{

msWord.Documentworddoc=wordapp.Documents.Open(file,refunknow,refunknow);

stringmystring=worddoc.Tables[1].Cell(1,4).Range.Text.Trim().ToString()

.Replace(" ","");

//河流

{

if(mystring=="河流")

{

stringfilename=this.textBox1.Text+

"\01陆地水系.xlsx";

stringconnectstring=string.Format

("Provider=Microsoft.Jet.OLEDB.4.0;

datasource=filename;ExtendedProperties

=' Excel8.0' ");

OleDbConnectionmyconn=newOleDbConnection

(connectstring);

myconn.Open();

excel.Applicationexcelapp=newMicrosoft

.Office.Interop.Excel.Application();

excel.Workbookbook=excelapp.Workbooks

.Open(filename,Missing.Value,false

,Missing.Value,Missing.Value,Missing

.Value,true,Missing.Value,Missing.Value

,Missing.Value,Missing.Value,Missing

.Value,Missing.Value,Missing.Value

,Missing.Value);

excel.Worksheetsheet=book.Worksheets

.get_Item(1);

introwsint=sheet.UsedRange.Cells.Columns

.Count;

introwsinti=sheet.UsedRange.Rows.Count;

sheet.Rows.Cells[1][m]=m-1;

sheet.Rows.Cells[2][m]="";

sheet.Rows.Cells[3][m]=worddoc.Tables[1]

.Cell(2,3).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[4][m]=worddoc.Tables[1]

.Cell(7,3).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[5][m]=worddoc.Tables[1]

.Cell(8,3).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[6][m]=worddoc.Tables[1]

.Cell(7,5).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[7][m]=worddoc.Tables[1]

.Cell(8,5).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[8][m]=worddoc.Tables[1]

.Cell(11,2).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[9][m]="";

sheet.Rows.Cells[10][m]="";

sheet.Rows.Cells[11][m]= "";

sheet.Rows.Cells[12][m]=worddoc.Tables[1]

.Cell(22,2).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[13][m]=worddoc.Tables[1]

.Cell(5,3).Range.Text.Trim().ToString()

.Replace(" ","").Remove(4,worddoc.Tables

[1].Cell(5,3).Range.Text.Trim()

.ToString().Replace(" ","").Length-4);

sheet.Rows.Cells[14][m]=worddoc.Tables[1]

.Cell(9,6).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[15][m]="2000";

sheet.Rows.Cells[16][m]="1∶50000";

sheet.Rows.Cells[17][m]="秘密";

sheet.Rows.Cells[18][m]="实测";

sheet.Rows.Cells[19][m]="不变";

sheet.Rows.Cells[20][m]=worddoc.Tables[1]

.Cell(20,2).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[21][m]=worddoc.Tables[1]

.Cell(23,2).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[22][m]=worddoc.Tables[1]

.Cell(23,6).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[23][m]="";

sheet.Rows.Cells[24][m]=@textBox2.Text;

sheet.Rows.Cells[25][m]="12100";

sheet.Rows.Cells[26][m]=worddoc.Tables[1]

.Cell(13,3).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[27][m]=worddoc.Tables[1]

.Cell(13,5).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[28][m]=worddoc.Tables[1]

.Cell(14,3).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[29][m]=worddoc.Tables[1]

.Cell(14,5).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[30][m]="请选择..";

sheet.Rows.Cells[31][m]="请选择..";

sheet.Rows.Cells[32][m]="请选择..";

sheet.Rows.Cells[33][m]=worddoc.Tables[1]

.Cell(16,3).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[34][m]=worddoc.Tables[1]

.Cell(16,5).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[35][m]=worddoc.Tables[1]

.Cell(10,2).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[36][m]=worddoc.Tables[1]

.Cell(19,3).Range.Text.Trim().ToString()

.Replace(" ","");

sheet.Rows.Cells[2][2]="3219c8ce-979d

-4e20-927c-21e742006fd2";

}

book.Save();

book.Close();

excelapp.Quit();

myconn.Close();

m++;

}

//瀑布

else if(mystring22 == "瀑布")

……

worddoc.Close(ref unknow,ref unknow

,ref unknow);

wordapp.Quit(ref unknow,ref unknow

,ref unknow);

……

MessageBox.Show("完成!!");

1.3程序运行界面

程序界面设计简单,如图1所示。运行时选择地名登记表所在文件夹以及地名属性表,然后填写行政区划,点击【确认】即可运行计算。程序界面中增加了类别名称检查,通过读取每一张地名登记表中的类别名称,判断是否属于第二次全国地名普查内容与指标中的一级、二级、三级类别名称,如果不属于则筛选出错误类型的地名登记表,确保所有导入到地名属性表中的属性都来源于正确类型的地名登记表,进而确保了数据批量录入的质量。

图1 程序运行界面Fig.1 Program operation interface

2 Excel数据的导入

云南省第二次全国地名普查数据建库与管理软件提供了地名属性表(Excel)导入,并且支持与地名相关的多媒体数据的导入。 Excel属性数据导入操作步骤如下:

第一步,打开菜单数据导入→Excel属性数据导入。

第二步,如果用户没有Excel模版整理数据的话,可以通过该功能下载模版;对于已经整理好Excel数据的用户,可以选择Excel地名属性数据所在的文件夹,点击【导入】,则可以将数据导入到系统中,并且在界面的列表中显示导入

的数据,如图2所示。

图2 导入数据界面Fig.2 Importing data interface

3 结束语

如果通过手动录入地名登记表到云南省第二次全国地名普查数据建库与管理软件将是一个复杂而又繁琐的工作,利用程序能够极大地提高工作效率。更重要的是,地名普查意义重大,一旦出现错误,影响范围大,影响时间长。实践证明,利用本文所编程序批量导入地名登记表能够大大降低录入出错的可能,确保数据的质量。

[1]云南省民政厅,江苏速度信息科技有限公司.云南省第二次全国地名普查数据建库与管理软件操作手册[K].江苏:江苏速度信息科技有限公司,2015.

[2]第二次全国地名普查领导小组办公室.第二次全国地名普查实施方案(国地名普查组发〔2014〕1号)[Z].北京:第二次全国地名普查领导小组办公室,2014.

[3]第二次全国地名普查领导小组办公室.第二次全国地名普查工作规程(国地名普查组发〔2014〕3号)[Z].北京:第二次全国地名普查领导小组办公室,2014.

[4]苑洲云,孔玲华,王海江.浅谈上虞地名普查数据快速建库的方法应用[J].浙江测绘,2011(1):26-27.

Realization of Batch Input of Place Names Registration Forms in Second National Census of Place Names

CHEN Ping1,GAO Shi-hua1,YANG Hai-guan2,DAI Jin-wen1

(1.Yunnan Institute of Surveying and Mapping Engineering,Kunming Yunnan 650034,China; 2.Yunnan Testing Station of Mapping and Surveying Products,Kunming Yunnan 650034,China)

Along with further development of Second National Census of Place Names,data input of place names registration forms has been basically completed,and how to efficiently and quickly input place names registration forms to place names census data management system has become very important.To this end,this article describes a method of batch inputing place names registration forms to place names property sheet based on C#,and then inputs place names property sheet to place names census data management system at once,which can greatly improve the work efficiency.

census of place names;place names registration form;batch input;C #

2016-05-11

P 208; P 209

A

1007-9394(2016)03-0018-03

陈平(1988~),男,湖南邵阳人,学士,助理工程师,现主要从事工程测量及地理信息应用方面的工作。

猜你喜欢

建库登记表批量
批量提交在配置分发中的应用
2021年山西省对口升学考试奖励照顾考生登记表
山西省成人高校招生录取照顾对象登记表
2020年山西省对口升学考试奖励照顾考生登记表
2019年山西省普通高校专升本选拔考试获奖考生照顾加分登记表
“数字温县”建设项目通过验收
高校图书馆回溯建库探微
基于VBA井斜数据批量校正方法
中文期刊回溯建库的实践与思考——以贵州省图书馆为例
在数控车床上批量钻铰孔类工件的实践