Bug 49564

Summary: getlocked return error value
Product: POI Reporter: longxibo
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: alain.perry
Priority: P2    
Version: 3.6-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: upload xlsx file for test
Screenshot for the cell property
locked property is true
locked property is false

Description longxibo 2010-07-06 20:59:35 UTC
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();
	    }
	}		
    }
Comment 1 longxibo 2010-07-06 21:05:05 UTC
Created attachment 25723 [details]
Screenshot for the cell property
Comment 2 Nick Burch 2010-07-07 09:47:00 UTC
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?
Comment 3 longxibo 2010-07-09 04:54:26 UTC
(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'?
Comment 4 Nick Burch 2010-07-09 05:04:50 UTC
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!
Comment 5 longxibo 2010-07-14 03:57:00 UTC
(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.
Comment 6 longxibo 2010-07-14 04:01:29 UTC
Created attachment 25761 [details]
locked property is true
Comment 7 longxibo 2010-07-14 04:03:08 UTC
Created attachment 25762 [details]
locked property is false
Comment 8 alain.perry 2011-05-27 16:45:41 UTC
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.
Comment 9 alain.perry 2011-05-27 16:46:47 UTC
I'm using poi-3.7-20101029 by the way.
Comment 10 Yegor Kozlov 2011-06-24 13:06:32 UTC
XSSFCellStyle.getLocked() returned false if the "locked" value was not set. The default value is true and I fixed it in  r1139288


Yegor