如何复制工作表保护选项?
How to copy worksheet protection options?
我正在使用 IXLWorksheet.CopyTo
方法将工作表从一个工作簿复制到另一个工作簿,但未复制保护选项。我认为这是设计使然,但我需要复制它们。
private void CopyProtectionOptions(IXLSheetProtection source, IXLSheetProtection target)
{
target.AutoFilter = source.AutoFilter;
target.DeleteColumns = source.DeleteColumns;
target.DeleteRows = source.DeleteRows;
target.FormatCells = source.FormatCells;
target.FormatColumns = source.FormatColumns;
target.FormatRows = source.FormatRows;
target.InsertColumns = source.InsertColumns;
target.InsertHyperlinks = source.InsertHyperlinks;
target.InsertRows = source.InsertRows;
target.Objects = source.Objects;
target.PivotTables = source.PivotTables;
target.Scenarios = source.Scenarios;
target.SelectLockedCells = source.SelectLockedCells;
target.SelectUnlockedCells = source.SelectUnlockedCells;
}
有没有比复制每个标志更好的方法"by-hand"?
不行,没有更好的办法。
您不能复制完整的保护对象,因为它包括加密的密码。
我正在使用 IXLWorksheet.CopyTo
方法将工作表从一个工作簿复制到另一个工作簿,但未复制保护选项。我认为这是设计使然,但我需要复制它们。
private void CopyProtectionOptions(IXLSheetProtection source, IXLSheetProtection target)
{
target.AutoFilter = source.AutoFilter;
target.DeleteColumns = source.DeleteColumns;
target.DeleteRows = source.DeleteRows;
target.FormatCells = source.FormatCells;
target.FormatColumns = source.FormatColumns;
target.FormatRows = source.FormatRows;
target.InsertColumns = source.InsertColumns;
target.InsertHyperlinks = source.InsertHyperlinks;
target.InsertRows = source.InsertRows;
target.Objects = source.Objects;
target.PivotTables = source.PivotTables;
target.Scenarios = source.Scenarios;
target.SelectLockedCells = source.SelectLockedCells;
target.SelectUnlockedCells = source.SelectUnlockedCells;
}
有没有比复制每个标志更好的方法"by-hand"?
不行,没有更好的办法。
您不能复制完整的保护对象,因为它包括加密的密码。