资源简介

使用步骤: 1. 使用Microsoft Visual Studio 2008打开解决方案,并重新编译; 2. 重新编译后在解决方案文件同级的目录下会产生两个文件夹,分别是BinD和WorkEnvironment; 3. 拷贝BinD目录下的CustomContextMenuStrip.dll到 SuperMap Deskpro .NET的安装目录下..Bin/Plugins/CustomContextMenuStrip文件夹中,如果CustomContextMenuStrip不存在,请先新建一个。 4. 拷贝WorkEnvironment目录下的 CustomContextMenuStrip.config到SuperMap Deskpro .NET的安装目录下..WorkEnvironment/Default文件夹中。 5.打开矢量数据集后点击右键,弹出右键菜单,如示意图1所示,将选中的数据集属性导出到Excel文件中。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using SuperMap.Desktop;
using Application = SuperMap.Desktop.Application;
using SuperMap.Data;

namespace CustomContextMenuStrip
{
    class MyCtrlAction : CtrlAction
    {
        override public void Run()
        {
            try
            {
                //定位到某个表中
                Microsoft.Office.Interop.Excel.Application myexcel = new Microsoft.Office.Interop.Excel.Application();
                Microsoft.Office.Interop.Excel.Workbooks workbooks = myexcel.Workbooks;
                Microsoft.Office.Interop.Excel.Workbook workbook =
                    workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
                ;
                Microsoft.Office.Interop.Excel.Worksheet sheet =
                    (Microsoft.Office.Interop.Excel.Worksheet) workbook.Worksheets[1];

                Microsoft.Office.Interop.Excel.Range range = sheet.Columns.get_Range(“H:H“ Type.Missing);
                range.Validation.Delete();
                range.Validation.Add(Microsoft.Office.Interop.Excel.XlDVType.xlValidateList
                                     Microsoft.Office.Interop.Excel.XlDVAlertstyle.xlValidAlertStop Type.Missing
                                     “123“ Type.Missing);

                //获取数据集属性
                Dataset[] activeDatasets = Application.ActiveDatasets;
                if (activeDatasets.Length != 0)
                {
                    Dataset dataset = activeDatasets[0];
                    if (dataset.Type == DatasetType.Point || dataset.Type == DatasetType.Region ||
                        dataset.Type == DatasetType.Line)
                    {
                        //确定选中的数据集
                        DatasetVector Dtv_Aim = dataset as DatasetVector;

                        FieldInfos fieldInfos = Dtv_Aim.FieldInfos;

                        //赋字段名
                        for (int i = 1; i < fieldInfos.Count + 1; i++)
                        {
                            sheet.Cells[1 i] = fieldInfos[i - 1].Name.ToString();
                        }

                        Recordset recordset = Dtv_Aim.GetRecordset(false CursorType.Dynamic);
                        if (recordset.RecordCount != 0)
                        {
                            //弹出保存Excel对话框
                            SaveFileDialog saveFileDialog = new SaveFileDialog();
                            saveFileDialog.Filter = “*.xlsx|*.xlsx“;
                            if (saveFileDialog.ShowDialog() == DialogResult.OK)
                            {

                                recordset.MoveFirst();
                                int j = 2;
                                while (!recordset.IsEOF)
                                {
                                    object[] value = recordset.GetValues();
                                    for (i

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\
     文件        1074  2012-05-10 22:12  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\CustomContextMenuStrip.config
     文件        6656  2012-05-10 22:12  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\CustomContextMenuStrip.dll
     文件       15872  2012-05-10 22:12  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\CustomContextMenuStrip.pdb
     文件     1100392  2007-10-10 09:48  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\Microsoft.Office.Interop.Excel.dll
     文件     1309492  2005-04-19 14:48  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\Microsoft.Office.Interop.Excel.xml
     文件       20080  2007-10-10 09:48  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\Microsoft.Office.Interop.SmartTag.dll
     文件       64088  2007-10-10 09:48  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\Microsoft.Vbe.Interop.dll
     文件      223800  2007-10-10 09:48  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\office.dll
     文件      387947  2005-04-19 14:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\office.xml
     文件     6155776  2012-03-31 09:36  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\SuperMap.Data.dll
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\zh-CN\
     文件      114688  2012-03-31 09:36  CustomContextMenuStrip(修改)\CustomContextMenuStrip\BinD\zh-CN\SuperMap.Data.resources.dll
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\$SuperMapDesktopHome$\
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\$SuperMapDesktopHome$\Bin\
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\$SuperMapDesktopHome$\Bin\Plugins\
     目录           0  2012-05-11 08:25  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\$SuperMapDesktopHome$\Bin\Plugins\CustomContextMenuStrip\
     文件        4494  2012-04-08 15:59  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\CtrlAction.cs
     文件        1021  2012-05-11 09:05  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\CustomContextMenuStrip.config
     文件        4945  2012-05-10 22:12  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\CustomContextMenuStrip.csproj
     文件        1048  2012-04-08 16:26  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\CustomContextMenuStrip.csproj.user
     文件         524  2012-04-08 15:23  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\DesktopPlugin.cs
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\obj\
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\obj\X86\
     目录           0  2012-05-11 08:42  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\obj\X86\Debug\
     文件        1748  2012-05-10 22:12  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\obj\X86\Debug\CustomContextMenuStrip.csproj.FileListAbsolute.txt
     文件        6656  2012-05-10 22:12  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\obj\X86\Debug\CustomContextMenuStrip.dll
     文件       15872  2012-05-10 22:12  CustomContextMenuStrip(修改)\CustomContextMenuStrip\CustomContextMenuStrip\obj\X86\Debug\CustomContextMenuStrip.pdb
............此处省略10个文件信息

评论

共有 条评论