2

After protected the sheet.

sheet.protectSheet("");

Not able to enable sorting.

The new version of POI. Not have an argument to enable the sortingin a protected sheet. It has only to disable sorting.

sheet.lockSort();

I tried this also.

CTSheetProtection sheetProtection = excelSheet.getCTWorksheet().getSheetProtection();
        sheetProtection.setSort(false);

But this function enables the sorting button in excel sheet. But after I click the A-Z or Z-A I am getting the pop-up. Because of the sheet protection.

I am using this <version>3.10.1</version>. I am using a protection method for the user do not edit some column in sheet. But I need sorting in a protected sheet.

One more question also. Is this possible to lock the first row of excel. Because do not sort the title row. But I used

sheet.createFreezePane(0, 1);

This will freeze from scrolling, not from the sorting. Please help with these two questions.

Sofo Gial
  • 697
  • 1
  • 9
  • 20
Joel Java
  • 21
  • 3
  • https://stackoverflow.com/questions/50155205/enable-filtering-and-sorting-in-a-protected-sheet-using-apache-poi/50186830#50186830 – Axel Richter Jun 10 '19 at 10:48
  • 1
    Btw.: `apache poi` version `3.10.1` is too old to use. Do using the latest stable version which currently is `4.1.0`. – Axel Richter Jun 10 '19 at 11:00

0 Answers0