本文整理汇总了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);
}
示例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 { }
}
示例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 { }
}
示例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 { }
}
示例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;
}
示例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;
}