저는 Apache POI를 사용하여 Excel 파일 (2007)을 생성하고 있습니다. 제가 원했던 것은 시트를 보호하는 것입니다.하지만 몇 가지 옵션을 사용할 수 있습니다. 옵션으로, Excel 응용 프로그램에서 시트를 보호하려고 할 때 확인란을 의미합니다 ("이 워크 시트의 모든 사용자에게 레이블 허용"레이블 아래에 있음). 특히, "잠긴/열어 본 셀 선택", "서식 열", "정렬"및 "자동 필터 허용"을 활성화하려고합니다. 고마워요! : DApache POI - 옵션으로 시트를 보호하는 방법?
10
A
답변
10
Apache POI 3.9에서는 잠금 기능을 활성화하여 XSSF 시트 보호를 사용할 수 있습니다. 심지어 당신은 몇 가지 엑셀 개체를 엑셀 개체 (즉, 텍스트 상자) 잠금을 해제하고 나머지는 잠겨 있지 않은 경우 아래에 잠금 해제로 남길 수 있습니다.
private static void lockAll(Sheet s, XSSFWorkbook workbookx){
String password= "abcd";
byte[] pwdBytes = null;
try {
pwdBytes = Hex.decodeHex(password.toCharArray());
} catch (DecoderException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
XSSFSheet sheet = ((XSSFSheet)s);
removePivot(s,workbookx);
sheet.lockDeleteColumns();
sheet.lockDeleteRows();
sheet.lockFormatCells();
sheet.lockFormatColumns();
sheet.lockFormatRows();
sheet.lockInsertColumns();
sheet.lockInsertRows();
sheet.getCTWorksheet().getSheetProtection().setPassword(pwdBytes);
for(byte pwdChar :pwdBytes){
System.out.println(">>> Sheet protected with '" + pwdChar + "'");
}
sheet.enableLocking();
workbookx.lockStructure();
}
5
어떤 기능을 선택할 수없는 경우가 있습니다. 모두 또는 아무것도 아닙니다. 이것은 현재 Apache Poi의 알려진 버그입니다. 출처 : https://issues.apache.org/bugzilla/show_bug.cgi?id=51483
는 다음과 같은 해결 방법을 사용하여이 문제를 해결할 수 있습니다 내가()`설정() 메소드`sheet.getSettings 이상으로 생각하지 말아
xssfSheet.enableLocking();
CTSheetProtection sheetProtection = xssfSheet.getCTWorksheet().getSheetProtection();
sheetProtection.setSelectLockedCells(true);
sheetProtection.setSelectUnlockedCells(false);
sheetProtection.setFormatCells(true);
sheetProtection.setFormatColumns(true);
sheetProtection.setFormatRows(true);
sheetProtection.setInsertColumns(true);
sheetProtection.setInsertRows(true);
sheetProtection.setInsertHyperlinks(true);
sheetProtection.setDeleteColumns(true);
sheetProtection.setDeleteRows(true);
sheetProtection.setSort(false);
sheetProtection.setAutoFilter(false);
sheetProtection.setPivotTables(true);
sheetProtection.setObjects(true);
sheetProtection.setScenarios(true);
+0
나는 XSSFSheet 개체를 사용하고 있습니다. 내 시트를 보호하면서 Excel의 모든 필터 지우기 옵션을 활성화하는 방법이 있습니다. 어떤 제안? –
관련 문제
- 1. Apache POI. 시트 복사
- 2. Apache POI XSSF를 사용하여 오른쪽에서 왼쪽 정렬로 시트를 만드는 방법
- 3. IKVM Apache POI 방법
- 4. Apache OFBiz에서 Apache POI 예외
- 5. Apache POI 컴파일 오류
- 6. Apache POI - .html 스프레드 시트를 .xls 스프레드 시트로 변환
- 7. Apache POI 행 번호
- 8. Apache POI 데이터 형식
- 9. Apache POI : 워크 시트를 비교하는 쉬운 방법은 무엇입니까?
- 10. android apache poi error
- 11. Apache Poi - Algo
- 12. Apache POI - 단일 열 반복
- 13. Apache POI - Docx 출력 문제
- 14. Apache POI 및 Aspose?
- 15. 자바 이클립스 apache poi
- 16. Apache POI org.apache.poi.ss.formula.FormulaParseException
- 17. Apache POI Word 자습서.
- 18. Apache poi 날짜 형식
- 19. Apache POI 시간 셀
- 20. Apache-POI 필드 형성
- 21. Java Apache poi
- 22. Apache POI 종속성은 무엇입니까?
- 23. Apache POI Comment Excel
- 24. Android에서 Apache POI 사용
- 25. Apache POI Shift Row
- 26. Apache POI 및 EXCEL
- 27. Apache POI - XSSF : Row.getCell()
- 28. excel java apache poi
- 29. Apache POI 출력 문제
- 30. Apache POI 종속성
, 당신은 아무것도 할 수 있습니다. – TheWhiteRabbit
sheet.getSettings()는 Apache POI가 아니라 JExcel에서 가져온 것입니다. – Jairo