当前位置: 首页>>代码示例>>C#>>正文


C# Worksheet.Unprotect方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Excel.Worksheet.Unprotect方法的典型用法代码示例。如果您正苦于以下问题:C# Worksheet.Unprotect方法的具体用法?C# Worksheet.Unprotect怎么用?C# Worksheet.Unprotect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Excel.Worksheet的用法示例。


在下文中一共展示了Worksheet.Unprotect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: handleProp

        protected void handleProp(QueryServiceControl.QueryServiceManager.property property)
        {
            string id = property.names.id;

            //Removing the institution identifying prefix from CADSR elements on client request
            if (id.Contains("-CADSR-"))
            {
                string[] idarr = id.Split('-');
                id = idarr[idarr.Length - 2] + " v." + idarr[idarr.Length - 1];
            }

            string preferredName = property.names.preferred;
            string definition = QueryServiceControl.QueryServiceControl.getDefinition(property.definition);
            string label = preferredName;

            //Get selected range
            Excel.Range selected = (Excel.Range)application.Selection;
            if (selected.Value2 == null || selected.Value2.ToString().Length == 0)
            {
                selected.Value2 = label;
            }
            else
            {
                //Refuse to add?  Do you have to remove first?
            }

            //Create concept list if not exists

            propList = useList(propList, "prop_list");

            //Add new concept entry to concept_list
            propList.Unprotect(dummyPass);
            Excel.Range c = (Excel.Range)propList.Cells[2, 1];

            Excel.Range found = propList.Cells.Find(id, Type.Missing, Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, false, Type.Missing, Type.Missing);
            if (found == null) //if (existingIndex == 0)
            {
                for (int i = 3; c.Value2 != null; i++)
                {
                    c = (Excel.Range)ocList.Cells[i, 1];

                }

                c.Value2 = id;
                c.Next.Value2 = preferredName;
                c.Next.Next.Value2 = definition.Trim().Replace("&gt;", ">").Replace("&lt;", "<").Replace("&amp;", "&");
                //c.Next.Next.Next.Value2 = attr.Trim().Replace(",", "\n\n").Replace("&#44;", ", ").Replace("&gt;", ">").Replace("&lt;", "<").Replace("&amp;", "&");

                //Cells mapped counter
                c.Next.Next.Next.Next.Value2 = 1;
            }
            else
            {
                found.Next.Next.Next.Next.Value2 = 1 + Convert.ToInt16(found.Next.Next.Next.Next.Value2.ToString());
            }

            propList.Protect(dummyPass, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

            /* Remove hyperlinks for now until a suitable two way link method is found */
            selected.Hyperlinks.Add(selected, "", getSelectedRangeAddress(c), Type.Missing, label);

            selected.Font.Bold = true;
            selected.Font.Underline = false;
            selected.Font.ColorIndex = 1;
            selected.Interior.ThemeColor = Excel.XlThemeColor.xlThemeColorAccent3;
            selected.Interior.TintAndShade = 0.2;
        }
开发者ID:NCIP,项目名称:cagrid-grid-incubation,代码行数:67,代码来源:ExcelQueryServiceControl.cs

示例2: handleCommon

        /// <summary>
        /// Handles insertion of common class elements into worksheet.
        /// 
        /// TODO: Refactor code
        /// </summary>
        /// <param name="selectedNode">Common Class element element to use</param>
        protected void handleCommon(XElement selectedNode, string name, bool annotate)
        {
            string id = selectedNode.Element(rs + "names").Element(rs + "id").Value;
            string fullId = selectedNode.Element(rs + "names").Element(rs + "id").Value;
            //Removing the institution identifying prefix from CADSR elements on client request
            if (id.Contains("-CADSR-"))
            {
                string[] idarr = id.Split('-');
                id = idarr[idarr.Length - 2] + "v" + idarr[idarr.Length - 1];
            }

            string preferredName = selectedNode.Element(rs + "names").Element(rs + "preferred").Value;
            string definition = selectedNode.Element(rs + "definition").Value;
            if (definition == null || definition.Length == 0)
            {
                definition = "(No definition supplied)";
            }
            else
            {
                //Handle special caDSR/EVS format
                definition = definition.Trim().Replace("&gt;", ">").Replace("&lt;", "<").Replace("<![CDATA[", "").Replace("]]>", "");
                if (definition.Contains("<def-source>"))
                {
                    XElement e = XElement.Parse("<def>" + definition + "</def>");
                    definition = e.Element("def-definition").Value + "\n(Source: " + e.Element("def-source").Value + ")";
                }
            }
            string attr = createAttrs(selectedNode, name);
            string label = id + ":" + preferredName;
            string[] concepts = null;
            Excel.Range selected = (Excel.Range)application.Selection;
            string hLinkLabel = "";

            if (annotate && (!name.Equals("vd") && !name.Equals("dec") && !name.Equals("cd")))
            {
                concepts = extractConcepts(attr).Split(';');
                Excel.Range leftCell = selected.get_Offset(0, -1);
                string prim = concepts[concepts.Length - 1];
                string quals = "";
                for (int i = 0; i < concepts.Length - 1; i++)
                    quals += concepts[i] + ";";

                if (quals.Length > 0)
                    quals = quals.Substring(0, quals.Length - 1);

                if ((selected.Value2 == null || selected.Value2.ToString().Length == 0) && (((leftCell.Value2 == null || leftCell.Value2.ToString().Length == 0) || quals.Length == 0)))
                {
                    selected.Value2 = prim;
                    hLinkLabel = prim;
                    if (quals.Length > 0)
                        leftCell.Value2 = quals;
                }
            }
            else
            {
                //Get selected range

                if (selected.Value2 == null || selected.Value2.ToString().Length == 0)
                {
                    selected.Value2 = label;
                    hLinkLabel = label;
                }
                else
                {
                    //Refuse to add?  Do you have to remove first?
                }
            }
            // empty hlink indicates non-empty cell.  don't overwrite
            if (hLinkLabel.Length > 0)
            {

            //Create concept list if not exists

            propList = useList(propList, name + "_list");

            //Add new concept entry to concept_list
            propList.Unprotect(dummyPass);
            Excel.Range c = (Excel.Range)propList.Cells[2, 1];

            Excel.Range found = propList.Cells.Find(id, Type.Missing, Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, false, Type.Missing, Type.Missing);
            if (found == null) //if (existingIndex == 0)
            {
                for (int i = 3; c.Value2 != null; i++)
                {
                    c = (Excel.Range)propList.Cells[i, 1];

                }

                c.Value2 = fullId;
                c.Next.Value2 = preferredName;
                c.Next.Next.Value2 = definition.Trim().Replace("&gt;", ">").Replace("&lt;", "<").Replace("&amp;", "&");
                c.Next.Next.Next.Value2 = attr.Trim().Replace(",", "\n\n").Replace("&#44;", ", ").Replace("&gt;", ">").Replace("&lt;", "<").Replace("&amp;", "&");

                //Cells mapped counter
//.........这里部分代码省略.........
开发者ID:NCIP,项目名称:cadsr-cgmdr,代码行数:101,代码来源:ExcelQueryServiceControl.cs

示例3: handleProp

        protected void handleProp(XElement selectedNode)
        {
            string id = selectedNode.Element(rs + "names").Element(rs + "id").Value;

            //Removing the institution identifying prefix from CADSR elements on client request
            if (id.Contains("-CADSR-"))
            {
                string[] idarr = id.Split('-');
                id = idarr[idarr.Length - 2] + " v." + idarr[idarr.Length - 1];
            }

            string preferredName = selectedNode.Element(rs + "names").Element(rs + "preferred").Value;
            string definition = selectedNode.Element(rs + "definition").Value;
            if (definition == null || definition.Length == 0)
            {
                definition = "(No definition supplied)";
            }
            else
            {
                //Handle special caDSR/EVS format
                definition = definition.Trim().Replace("&gt;", ">").Replace("&lt;", "<").Replace("<![CDATA[", "").Replace("]]>", "");
                if (definition.Contains("<def-source>"))
                {
                    XElement e = XElement.Parse("<def>" + definition + "</def>");
                    definition = e.Element("def-definition").Value + "\n(Source: " + e.Element("def-source").Value + ")";
                }
            }

            string label = preferredName;

            //Get selected range
            Excel.Range selected = (Excel.Range)application.Selection;
            if (selected.Value2 == null || selected.Value2.ToString().Length == 0)
            {
                selected.Value2 = label;
            }
            else
            {
                //Refuse to add?  Do you have to remove first?
            }

            //Create concept list if not exists

            propList = useList(propList, "prop_list");

            //Add new concept entry to concept_list
            propList.Unprotect(dummyPass);
            Excel.Range c = (Excel.Range)propList.Cells[2, 1];

            Excel.Range found = propList.Cells.Find(id, Type.Missing, Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, false, Type.Missing, Type.Missing);
            if (found == null) //if (existingIndex == 0)
            {
                for (int i = 3; c.Value2 != null; i++)
                {
                    c = (Excel.Range)ocList.Cells[i, 1];

                }

                c.Value2 = id;
                c.Next.Value2 = preferredName;
                c.Next.Next.Value2 = definition.Trim().Replace("&gt;", ">").Replace("&lt;", "<").Replace("&amp;", "&");
                //c.Next.Next.Next.Value2 = attr.Trim().Replace(",", "\n\n").Replace("&#44;", ", ").Replace("&gt;", ">").Replace("&lt;", "<").Replace("&amp;", "&");

                //Cells mapped counter
                c.Next.Next.Next.Next.Value2 = 1;
            }
            else
            {
                found.Next.Next.Next.Next.Value2 = 1 + Convert.ToInt16(found.Next.Next.Next.Next.Value2.ToString());
            }

            propList.Protect(dummyPass, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

            /* Remove hyperlinks for now until a suitable two way link method is found */
            selected.Hyperlinks.Add(selected, "", getSelectedRangeAddress(c), Type.Missing, label);

            selected.Font.Bold = true;
            selected.Font.Underline = false;
            selected.Font.ColorIndex = 1;
            selected.Interior.ThemeColor = Excel.XlThemeColor.xlThemeColorAccent3;
            selected.Interior.TintAndShade = 0.2;
        }
开发者ID:NCIP,项目名称:cadsr-cgmdr-nci-uk,代码行数:82,代码来源:ExcelQueryServiceControl.cs


注:本文中的Microsoft.Office.Interop.Excel.Worksheet.Unprotect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。