• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Apache POI: protect only some cells excel sheet

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
E torres
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic