Locking a cell does nothing if the sheet is not protected , that is, using the cfspreadsheet password attribute. But it also has some negative side effects ...
Sheet protection blocks all cells. This means that you need to “unlock” everything else using the format. Theoretically, you can simply unlock the whole sheet:
<cfset SpreadsheetFormatCellRange (sheet, {locked=false}, 1, 1, maxRow, maxCol)>
However, this has the unpleasant effect of populating each individual cell on the sheet. Therefore, if you read the file in the query, the query will contain ~ 65,536 rows and 256 columns. Even if you just filled in a few cells explicitly.
The lock function is better suited for cases when you want everything to be locked, except for a few cells (and not vice versa). If this is not what you are doing, I probably would not bother with it, given all the negative side effects.
Side effect example
<cfset testFile = "c:/test.xls"> <cfset sheet = spreadsheetNew()> <cfset SpreadsheetFormatCellRange (sheet, {locked=false}, 1, 1, 100, 10)> <cfset SpreadsheetSetCellValue(sheet,"LOCKED",1,1)> <cfset SpreadsheetSetCellValue(sheet,"UNLOCKED",2,1)> <cfset SpreadsheetFormatCell(sheet, {locked=true}, 1, 1)> <cfspreadsheet action="write" name="sheet" fileName="#testFile#" password="" overwrite="true" > <cfspreadsheet action="read" query="sheetData" src="#testFile#" > <cfdump var="#sheetData#" label="Lots of empty cells" />