zoukankan      html  css  js  c++  java
  • C#获取word 复选框问题

    DLL: Aspose.Words

      //判断表的列是否有word书签
                    if (doc.Range.Bookmarks.Any(p => p.Name.ToLower() == columnName.ToLower()))
                    {
                        //单选框
                        if ("YD,FC,ZBZH,WCFWNCJ,CLCW,CLFT,YTWSHT".Contains(columnName.ToUpper()))
                        {
                            Shape shape = (Shape)doc.GetChild(NodeType.Shape, j, true);
                            if (shape != null)
                            {
                                OleControl oleControl = shape.OleFormat.OleControl;
                                if (oleControl.IsForms2OleControl)
                                {
                                    Forms2OleControl checkBox = (Forms2OleControl)oleControl;
                                    switch (checkBox.Caption)
                                    {
                                        case "用地":
                                            columnName = "YD";
                                            break;
                                        case "房产":
                                            columnName = "FC";
                                            break;
                                        case "坐标转换":
                                            columnName = "ZBZH";
                                            break;
                                        case "误差范围内重界":
                                            columnName = "WCFWNCJ";
                                            break;
                                        case "测量错误":
                                            columnName = "CLCW";
                                            break;
                                        case "使用分图":
                                            columnName = "CLFT";
                                            break;
                                        case "原图为手画图":
                                            columnName = "YTWSHT";
                                            break;
                                    }
                                    updVal = checkBox.Value;
                                    j++;
                                }
                            }
    
    
                        }
                    }
    

      

     Aspose.Words.Document doc = new Aspose.Words.Document("word路径");
     foreach (DataColumn column in SQBModel.Tables[0].Columns)
     {
         //判断表的列是否有word书签
         if (doc.Range.Bookmarks.Any(p => p.Name.ToLower() == column.ColumnName.ToLower()))
         {
             string updVal = doc.Range.Bookmarks[column.ColumnName] != null ? doc.Range.Bookmarks[column.ColumnName].Text.Trim().Replace("a", "") : SQBModel.Tables[0].Rows[i][column.ColumnName].ToString().Trim().Replace("a", "");
             var mark = System.Text.RegularExpressions.Regex.Replace(updVal, @"[u4e00-u9fa5]", "").Replace("a", "");
             //获取复选框的特殊字符编码(根据word而定 我的%EF%81%92是选中 %EF%82%A3是没选中 )
             var urlEncode = HttpUtility.UrlEncode(mark);
             //选中
             if (urlEncode.ToUpper() == "%EF%81%92")
             {
                 updVal = "1";
             }//没选中
             else if (urlEncode.ToUpper() == "%EF%82%A3")
             {
                 updVal = "0";
             }
           }
      }
    好好学习,天天向上。
  • 相关阅读:
    项目中使用Redis的游标scan的一些小问题
    mac上使用Sequel Pro工具SSH连接数据库
    virtualbox通过Nat模式上网,宿主机与宿主机互通
    Mac系统docker初探
    QQ互联,填写回调时注意事项
    Centos中编辑php扩展库
    samba服务介绍
    bash常用功能
    vsftp服务介绍与相关实验
    shell概述与echo命令
  • 原文地址:https://www.cnblogs.com/Zhengxue/p/14607016.html
Copyright © 2011-2022 走看看