Не разрешать изменение формата в столбце Excel в java - PullRequest
0 голосов
/ 12 февраля 2020

У меня есть приложение, которое обеспечивает загрузку файла Excel, и я хотел бы заблокировать формат столбцов, чтобы они всегда были текстовыми.

Я пытаюсь использовать CTSheetProtection, когда я нажимаю, чтобы вставить значения в Excel файл попросить пароль ...

Sheet sheet = workbook.createSheet("Test");    
XSSFSheet xSheet = (XSSFSheet) sheet;
    xSheet.enableLocking();
    CTSheetProtection sheetProtection = xSheet.getCTWorksheet().getSheetProtection();

    sheetProtection.setSelectLockedCells(false);
    sheetProtection.setSelectUnlockedCells(false);
    sheetProtection.setFormatCells(true);
    sheetProtection.setFormatColumns(true);
    sheetProtection.setFormatRows(true);
    sheetProtection.setInsertColumns(false);
    sheetProtection.setInsertRows(false);
    sheetProtection.setInsertHyperlinks(false);
    sheetProtection.setDeleteColumns(false);
    sheetProtection.setDeleteRows(false);
    sheetProtection.setSort(false);
    sheetProtection.setAutoFilter(false);
    sheetProtection.setPivotTables(false);
    sheetProtection.setObjects(false);
    sheetProtection.setScenarios(false);
...