2015-11-02 51 views
1

我使用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; 
} 

是否有更好的方法,然後只是複製每個國旗「手邊」?

回答

0

不,沒有更好的辦法。

您不能複製完整的保護對象,因爲它包含加密的密碼。

+0

看起來你是對的。這個'CopyProtectionOptions'方法在ClosedXML API中非常方便,而不是客戶端代碼。 – astef