*
The moose likes Other Open Source Projects and the fly likes Apache POI: protect only some cells excel sheet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Apache POI: protect only some cells excel sheet" Watch "Apache POI: protect only some cells excel sheet" New topic
Author

Apache POI: protect only some cells excel sheet

E torres
Greenhorn

Joined: Nov 07, 2013
Posts: 4
Hi,
I am trying to protect an excel sheet using Apache POI so that no Cell in the sheet can be written to but the cells in column C that must be editable. The problem is that my code is resulting in NONE of the excel being editable. This is the code I am using:



I debugged this and the issue seems to be that this line is returning null:
Cell c = r.getCell(editableColumn);
The columm exist, but no cell in it has value. Actually, this is the reason why this column needs to be editable. This column will be filled later, and I have to make sure that only this column will be edited (and therefore I am trying to protect the rest of sheet). How could I set this empty column to NOT locked?
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7554
    
  18

E torres wrote:I am trying to protect an excel sheet using Apache POI so that no Cell in the sheet can be written to but the cells in column C that must be editable.

E torres,

I've moved your topic to a more suitable forum, as POI is quite specialized. You should get more answers there.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
E torres
Greenhorn

Joined: Nov 07, 2013
Posts: 4
Since I am already iterating I am considering this:


Still it feels like a ugly hack. For starters not being able to work directly with columns in an excel document feels weird (I am talking about the part in which I got to iterate over all the rows and set the protection options cell by cell), and now on the top of that if the document has a cell empty cannot work with it.
I am not complicating things too much? Does not exist a more intuitive/clear way of stating a column must be protected/unprotected?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Apache POI: protect only some cells excel sheet
 
Similar Threads
Read a .xls,.xlsx file format using XSSF
Detect filter in excel sheet using Apache POI
Extra double quote introduced when using POI
Using ApachePOI
Apache POI :Export to xls(Coloured Cell) not working in MS Excel