IGeometry Interface信息,只帮忙翻译了它的Description

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是基于ArcGIS Engine的信息系统代码示例,实现了您所需的功能: ```c# private void btnSearch_Click(object sender, EventArgs e) { // 获取用户输入的姓氏 string lastName = txtLastName.Text.Trim(); // 构造查询条件 string query = "用户名 LIKE '%" + lastName + "%'"; // 获取高坡镇宗地图的属性表 IFeatureLayer featureLayer = GetFeatureLayer("高坡镇宗地图"); ITable table = featureLayer as ITable; // 查询符合条件的记录 IQueryFilter queryFilter = new QueryFilterClass(); queryFilter.WhereClause = query; ICursor cursor = table.Search(queryFilter, true); // 高亮显示符合条件的宗地图斑 IFeatureCursor featureCursor = cursor as IFeatureCursor; IFeature feature = null; while ((feature = featureCursor.NextFeature()) != null) { IGeometry geometry = feature.Shape; IMxDocument mxDoc = (IMxDocument)ArcMap.Application.Document; IMap map = mxDoc.FocusMap; map.SelectFeature(featureLayer, feature); mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); } // 输出符合条件的记录到WORD文件中 try { // 创建一个新的WORD文档 Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application(); Document doc = wordApp.Documents.Add(); Paragraph paragraph; // 遍历查询结果,逐行输出到WORD文档中 IRow row = null; while ((row = cursor.NextRow()) != null) { string username = row.get_Value(row.Fields.FindField("用户名")).ToString(); paragraph = doc.Content.Paragraphs.Add(); paragraph.Range.Text = username; paragraph.Range.Font.Size = 12; paragraph.Range.InsertParagraphAfter(); } // 保存WORD文档并关闭 string filePath = @"C:\Users\Documents\output.docx"; doc.SaveAs2(filePath); doc.Close(); wordApp.Quit(); MessageBox.Show("查询结果已成功输出到WORD文档中!"); } catch (Exception ex) { MessageBox.Show("输出到WORD文档时出现错误:" + ex.Message); } } // 获取指定名称的要素图层 private IFeatureLayer GetFeatureLayer(string layerName) { IMxDocument mxDoc = (IMxDocument)ArcMap.Application.Document; IMap map = mxDoc.FocusMap; for (int i = 0; i < map.LayerCount; i++) { ILayer layer = map.get_Layer(i); if (layer is IFeatureLayer && layer.Name == layerName) { return layer as IFeatureLayer; } } return null; } ``` 代码中,我们使用了Microsoft Office Interop Word库来操作WORD文档。请注意,在使用这个库之前,您需要将其添加到项目的引用中。 在代码中,我们首先获取用户输入的姓氏,然后构造查询条件,在高坡镇宗地图的属性表中查询符合条件的记录。然后,我们使用ArcObjects中的SelectFeature方法高亮显示符合条件的宗地图斑。 接下来,我们遍历查询结果,逐行输出到WORD文档中。注意,我们在输出每一行记录时,使用了InsertParagraphAfter方法来插入一个新的段落。 最后,我们保存WORD文档并关闭。如果输出过程中出现了错误,我们将会捕获并显示错误信息
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值