2011-12-15 2 views

답변

9

엑셀 세포는 기본적으로 사용되는 잠겨 속성을 가지고있다. 그러나이 속성은 워크 시트의 보호 속성도 True으로 설정된 경우에만 호출됩니다. 워크 시트가 보호되어 있지 않으면 속성이 잠긴 속성이 무시됩니다.

따라서 귀하의 질문은 세포를 읽기 전용으로 만드는 방법이 가장 적합하지 않습니다.. 오히려, 문제는 워크 시트를 보호 한 후 셀을 편집 가능하게 만드는 방법입니다..

from xlwt import Workbook, Worksheet, easyxf 

# ... 

# Protect worksheet - all cells will be read-only by default 
my_worksheet.protect = True # defaults to False 
my_worksheet.password = "something_difficult_to_guess" 

# Create cell styles for both read-only and editable cells 
editable = easyxf("protection: cell_locked false;") 
read_only = easyxf("") # "cell_locked true" is default 

# Apply your new styles when writing cells 
my_worksheet.write(0, 0, "Can't touch this!", read_only) 
my_worksheet.write(2, 2, "Erase me :)", editable) 

# ... 

셀 스타일 (easyxf 클래스)도 등

건배 배경색, 글꼴 두께를 선언하는 데 유용합니다 :

은 ... 여기 있습니다.

+0

전체 Excel 파일을 암호로 보호해야하는 경우 어떻게해야합니까? –

관련 문제