Cell column and set the lock POI text

. 1          SXSSFWorkbook Workbook = new new SXSSFWorkbook ();
 2          the Font font = workbook.createFont ();
 . 3          the CellStyle style = workbook.createCellStyle ();
 . 4          style.setLocked ( to true ); // entire sheet to read-only 
. 5          the CellStyle notLockStyle = workbook.createCellStyle ();
 . 6          notLockStyle.setLocked ( to false ); // release can be modified column 
. 7  
. 8          the DataFormat workbook.createDataFormat the dataFormat = (); // set as editable text, edit does not automatically open the excel Science counting 
9         notLockStyle.setDataFormat (dataFormat.getFormat ( "@" ));
 10  
. 11          Sheet Sheet = wb.createSheet (title);
 12 is          sheet.protectSheet ( "123456"); // whole unprotected sheet, not otherwise edit mode does not take effect 
13          sheet.createRow the rowValues = row (rowIndex); // rowIndex line marked 
14          the Cell celValue = rowValue.createCell (the cellIndex); // the cellIndex column index 
15          celValue.setCellStyle (notLockStyle);

 

Guess you like

Origin www.cnblogs.com/laom2016/p/11942508.html