簡體   English   中英

Aspose Excel在受保護的工作表中排序

[英]Aspose excel sorting in protected worksheet

受保護的工作表是否可能允許排序?

嘗試了“允許用戶編輯范圍”,但是范圍內的單元格也是可編輯的,這是不期望的。

謝謝

請先取消工作表的保護,然后才能進行排序。 這也是Microsoft Excel行為。 請在此屏幕快照中查看Microsoft Excel的警告消息以供參考。

屏幕截圖: 在此處輸入圖片說明

注意: 我在Aspose擔任開發人員布道者

我已經嘗試過了,我通常在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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM