Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Apache POI: protect only some cells excel sheet

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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: 10777
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
We can walk to school together. And we can both read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic