Java 용 Aspose.Cells를 사용하면 쉽게 수행 할 수 있습니다. 당신은
- 먼저 아래의 샘플을 참조 워크 시트에
- 잠금 해제 특정 세포 또는 세포
의 범위를 모든 열 (모든 셀)을 잠글 수 있습니다.
String dataDir = "D:\\data\\";
// Create or load workbook
Workbook book = new Workbook();
// Get the first worksheet
Worksheet sheet = book.getWorksheets().get(0);
Style style;
StyleFlag flag = new StyleFlag();
// First lock all columns
for (int iCol=0 ; iCol<255 ; iCol++)
{
// Get style of the column
style = sheet.getCells().getColumns().get(iCol).getStyle();
// Apply locking to the style
style.setLocked(true);
flag.setLocked(true);
sheet.getCells().getColumns().get(iCol).applyStyle(style, flag);
}
// Get the range of cells, which we want to unlock
Range rangeUnlocked = sheet.getCells().createRange("A1:D4");
// Add a new style
int styleIndex = book.getStyles().add();
Style styleUnlocked = book.getStyles().get(styleIndex);
// Unlock cells
styleUnlocked.setLocked(false);
rangeUnlocked.setStyle(styleUnlocked);
// Protect the sheet
sheet.protect(ProtectionType.ALL);
//Save the Excel file
book.save(dataDir + "protectedrange.xlsx");
저는 개발자 전도사로 Aspose에서 일합니다.
ASPOSE는 Excel이 이러한 측면에서 작동하는 방식으로 작동하지 않습니까? 예 : 모든 셀이 기본적으로 잠겨 있습니다. * 보호를 적용하기 전에 4 개의 셀을 잠급니다. – pnuts
나는 스스로 aspose-cells에 대해 들어 본 적이 없으므로 내가 올바른 문서를 읽고 있는지는 모르지만 여기 : http://www.aspose.com/docs/display/cellsjava/Style'setLocked (booleanvalue)'가있다. method ... 그리고 yes 'Excel'은 모든 셀이 잠겨 있기 때문에 pnuts가 정확하다고 가정합니다. – chancea
@chancea는 셀에 스타일을 적용하기위한 것이 아닙니까? 내 말은 .. 난 잘 모르겠지만, 셀에서 스타일 편집을 잠 그거나 잠금 해제하는 것 같습니다. 어쨌든 그것을 확인해 볼게. – periback2