Created attachment 25722 [details] upload xlsx file for test @Test public void testGetLockedFromXlsx(){ XSSFWorkbook wb; XSSFSheet sheet; FileInputStream finput=null; File file; String xlsSourceFile = "c:\\testgetcellstyle.xlsx"; file = new File(xlsSourceFile); try { finput = new FileInputStream(file); wb = new XSSFWorkbook(finput); sheet = wb.getSheetAt(0); XSSFRow row = sheet.getRow(0); XSSFCell cell = row.getCell(25); XSSFCellStyle cellStyle = cell.getCellStyle(); assertTrue(cellStyle.getLocked());//CellStyle.getLocked() should will return true,But really return false } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally{ try { finput.close(); } catch (IOException e) { e.printStackTrace(); } } }
Created attachment 25723 [details] Screenshot for the cell property
I'd suggest that you unzip the file (.xlsx is actually a zip file of xml files), and start poking around to see where the locked property is actually set. Maybe it's not in the usual place?
(In reply to comment #2) > I'd suggest that you unzip the file (.xlsx is actually a zip file of xml > files), and start poking around to see where the locked property is actually > set. Maybe it's not in the usual place? Where is locked property in xml file? I can't found locked property in any xml file.This property name is 'locked' or 'lock'?
It could be in the cell styles file, or maybe in the sheet. I'd suggest you create two files, both with one cell, one locked and one not. Diff those to find out!
(In reply to comment #4) > It could be in the cell styles file, or maybe in the sheet. I'd suggest you > create two files, both with one cell, one locked and one not. Diff those to > find out! I change locked property and save file.Unzip two xlsx to diff directory.Compare two directory.I found style.xml have little diff. New style.xml add "<protection locked="0"/>" String,But old style.xml not "locked" property at all!It is Strange! I upload two file to investigation for you.
Created attachment 25761 [details] locked property is true
Created attachment 25762 [details] locked property is false
I'm being bit by this bug as well: getLocked() works perfectly fine with HSSF, but returns false on locked cells with XSSF. It's quite a pity.
I'm using poi-3.7-20101029 by the way.
XSSFCellStyle.getLocked() returned false if the "locked" value was not set. The default value is true and I fixed it in r1139288 Yegor