SL-13705 - lock all columns except C in the excel file (apparently google sheets does not respect this setting on import)

meow-7.2.2
Brad Payne (Vir Linden) 2020-09-14 20:34:51 +01:00
parent 822a4fb7d2
commit a1d24974e8
1 changed files with 10 additions and 6 deletions

View File

@ -235,14 +235,18 @@ def save_as_excel(data, lang):
workbook = writer.book
worksheet = writer.sheets['Sheet1']
cell_format = workbook.add_format({'text_wrap': True})
wrap_format = workbook.add_format({'text_wrap': True})
wrap_unlocked_format = workbook.add_format({'text_wrap': True, 'locked': False})
# Translators primarily care about columns A-C
worksheet.set_column('A:C', 100, cell_format)
worksheet.set_column('D:D', 50, cell_format, {'hidden': True})
worksheet.set_column('E:F', 30, cell_format, {'hidden': True})
# Translators primarily care about columns A-C, and should write
# only in column C. Can hide the others. Set widths.
worksheet.protect()
worksheet.set_column('A:B', 100, wrap_format)
worksheet.set_column('C:C', 100, wrap_unlocked_format)
worksheet.set_column('D:D', 50, wrap_format, {'hidden': True})
worksheet.set_column('E:F', 30, wrap_format, {'hidden': True})
# Lock the column header in place while scrolling
# Lock the top row (column headers) in place while scrolling
worksheet.freeze_panes(1, 0)
writer.save()