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


C# Microsoft.Office.Interop.Excel.Unprotect方法代码示例

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


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

示例1: WriteValueProtectedCell

 /// <summary>
 /// Schreibt einen Wert in die Zelle des gegebenen Excel-Sheets
 /// </summary>
 /// <param name="sheet">Das Excel Sheet.</param>
 /// <param name="zelle">Die Zelle, z. B. A2.</param>
 /// <param name="value">Den Wert der Zelle als String.</param>
 public void WriteValueProtectedCell(Excel.Worksheet sheet, string zelle, string value)
 {
     sheet.Unprotect("1111");
       Excel.Range r = sheet.get_Range(zelle, missing);
       r.Value2 = value;
       sheet.Protect("1111", false, true);
 }
开发者ID:TheTypoMaster,项目名称:diNo,代码行数:13,代码来源:ExcelTools.cs

示例2: unLockExcel

 /// <summary>
 /// 去保护工作表
 /// </summary>
 private void unLockExcel(Excel.Workbook wb, Excel.Worksheet xx)
 {
     try
     {
       
         
         xx.Unprotect("MyPassword");
         xx.EnableSelection = Microsoft.Office.Interop.Excel.XlEnableSelection.xlNoSelection;
         wb.SheetBeforeDoubleClick -= new Microsoft.Office.Interop.Excel.WorkbookEvents_SheetBeforeDoubleClickEventHandler(wb_SheetBeforeDoubleClick);  
     }
     catch { }
 }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:15,代码来源:frmTemplate.cs

示例3: unLockExcel

        private static void unLockExcel(Excel.Workbook wb, Excel.Worksheet xx)
        {
            try
            {


                xx.Unprotect("MyPassword");
                xx.EnableSelection = Microsoft.Office.Interop.Excel.XlEnableSelection.xlNoSelection;
              
            }
            catch { }
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:12,代码来源:Export20.cs

示例4: unLockExcel

        /// <summary>
        /// 去保护工作表
        /// </summary>
        public static void unLockExcel(Excel.Workbook wb, Excel.Worksheet xx)
        {
            try
            {


                xx.Unprotect("MyPassword");
                //xx.EnableSelection = Microsoft.Office.Interop.Excel.XlEnableSelection.xlNoSelection;
                //wb.SheetSelectionChange -= new Microsoft.Office.Interop.Excel.WorkbookEvents_SheetSelectionChangeEventHandler(Workbook_SheetSelectionChange);
                //wb.SheetBeforeDoubleClick -= new Microsoft.Office.Interop.Excel.WorkbookEvents_SheetBeforeDoubleClickEventHandler(wb_SheetBeforeDoubleClick);
            }
            catch { }
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:16,代码来源:RecordWorkTask.cs

示例5: UnprotectWorkbookStructure

        private Excel.Workbook UnprotectWorkbookStructure(Excel.Workbook workbook)
        {
            string workbookStructurePassword = string.Empty;

            int attemptCount = 0;

            // This code is based on a routine found here (public university, University of Wisconsin, Green Bay): https://uknowit.uwgb.edu/page.php?id=28850

            for (int i = 65; i < 67; i++)
                for (int j = 65; j < 67; j++)
                    for (int k = 65; k < 67; k++)
                        for (int l = 65; l < 67; l++)
                            for (int m = 65; m < 67; m++)
                                for (int i1 = 65; i1 < 67; i1++)
                                    for (int i2 = 65; i2 < 67; i2++)
                                        for (int i3 = 65; i3 < 67; i3++)
                                            for (int i4 = 65; i4 < 67; i4++)
                                                for (int i5 = 65; i5 < 67; i5++)
                                                    for (int i6 = 65; i6 < 67; i6++)
                                                        for (int n = 32; n < 126; n++)
                                                        {
                                                            workbookStructurePassword = Convert.ToChar(i).ToString() + Convert.ToChar(j).ToString() + Convert.ToChar(k).ToString() + Convert.ToChar(l).ToString() + Convert.ToChar(m).ToString() +
                                                                Convert.ToChar(i1).ToString() + Convert.ToChar(i2).ToString() + Convert.ToChar(i3).ToString() + Convert.ToChar(i4).ToString() + Convert.ToChar(i5).ToString() +
                                                                Convert.ToChar(i6).ToString() + Convert.ToChar(n).ToString();

                                                            attemptCount++;

                                                            try
                                                            {
                                                                workbook.Unprotect(workbookStructurePassword);
                                                            }
                                                            catch { }

                                                            if (!workbook.ProtectStructure)
                                                            {
                                                                return workbook;
                                                            }
                                                        }

            return null;
        }
开发者ID:turp182,项目名称:ExcelExposer,代码行数:41,代码来源:formMain.cs

示例6: UnprotectSheet

        private Excel.Worksheet UnprotectSheet(Excel.Worksheet sheet)
        {
            if (!string.IsNullOrEmpty(_worksheetPassword))
            {
                try
                {
                    sheet.Unprotect(_worksheetPassword);
                }
                catch
                {

                }

                if (!sheet.ProtectContents)
                {
                    return sheet;
                }
            }

            // This code is based on a routine found here (public university, University of Wisconsin, Green Bay): https://uknowit.uwgb.edu/page.php?id=28850

            int attemptCount = 0;

            for (int i = 65; i < 67; i++)
                for (int j = 65; j < 67; j++)
                    for (int k = 65; k < 67; k++)
                        for (int l = 65; l < 67; l++)
                            for (int m = 65; m < 67; m++)
                                for (int i1 = 65; i1 < 67; i1++)
                                    for (int i2 = 65; i2 < 67; i2++)
                                        for (int i3 = 65; i3 < 67; i3++)
                                            for (int i4 = 65; i4 < 67; i4++)
                                                for (int i5 = 65; i5 < 67; i5++)
                                                    for (int i6 = 65; i6 < 67; i6++)
                                                        for (int n = 32; n < 126; n++)
                                                        {
                                                            _worksheetPassword = Convert.ToChar(i).ToString() + Convert.ToChar(j).ToString() + Convert.ToChar(k).ToString() + Convert.ToChar(l).ToString() + Convert.ToChar(m).ToString() +
                                                                Convert.ToChar(i1).ToString() + Convert.ToChar(i2).ToString() + Convert.ToChar(i3).ToString() + Convert.ToChar(i4).ToString() + Convert.ToChar(i5).ToString() +
                                                                Convert.ToChar(i6).ToString() + Convert.ToChar(n).ToString();

                                                            attemptCount++;

                                                            try
                                                            {
                                                                sheet.Unprotect(_worksheetPassword);
                                                            }
                                                            catch { }

                                                            if (!sheet.ProtectContents)
                                                            {
                                                                return sheet;
                                                            }
                                                        }

            return null;
        }
开发者ID:turp182,项目名称:ExcelExposer,代码行数:56,代码来源:formMain.cs


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