![](/img/trans.png)
[英]Protected worksheet with Epplus - need to allow filtering and sorting. Sorting not permitted
[英]Aspose excel sorting in protected worksheet
受保護的工作表是否可能允許排序?
嘗試了“允許用戶編輯范圍”,但是范圍內的單元格也是可編輯的,這是不期望的。
謝謝
我已經嘗試過了,我通常在Filter中進行排序。 但是排序按鈕也是允許的。 首先將“過濾器”設置為開啟(可能是可選的)。 然后,您需要使用“允許用戶編輯范圍”,然后使用過濾器(可能是可選的)並啟用排序來保護工作表。
以下是在Excel中執行操作的步驟: https ://www.extendoffice.com/documents/excel/4673-excel-sort-filter-protected-sheet.html或以下網址中的解決方案1: http://blog.softartisans。 com / 2013/10/01 / kb-sorting-locked-cells-in-protected-worksheets /
這是Java的Aspose.Cells中的示例(在.net中應該類似):
Cells cells = sheet.getCells();
int maxCol = cells.getMaxDataColumn();
int maxRow = cells.getMaxDataRow();
sheet.getAutoFilter().setRange(0, 0, maxCol);
sheet.getAllowEditRanges().add("allowSortFilter", 0, 0, maxRow, maxCol);
Protection protection = sheet.getProtection();
protection.setAllowSelectingLockedCell(false);
protection.setAllowSelectingUnlockedCell(true);
protection.setAllowFiltering(true);
protection.setAllowSorting(true);
protection.setAllowEditingContent(false);
protection.setAllowEditingObject(false);
protection.setAllowEditingScenario(false);
protection.setPassword("password");
}
OoxmlSaveOptions opts = new OoxmlSaveOptions(SaveFormat.XLSX);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.