This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating protected excel sheets

 
Faras Dewal
Greenhorn
Posts: 2
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a servlet to generate an excel sheet.
The code is given below:




I want to make the first column of the excel sheet readonly.
Please help!!
 
Tim Moores
Bartender
Posts: 2686
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not generating an Excel document, you're generating HTML, which some spreadsheet applications (like Excel) happen to be able to read. If you want to use actual spreadsheet-like functionality, you'll need to generate actual XLS or XLSX documents, possibly using a library like Apache POI.

I'm not sure it's possible to protect individual columns, though; I seem to recall that being a per-sheet (or even per-file) setting.
 
Faras Dewal
Greenhorn
Posts: 2
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks tim.
is there some other way of generating an excel sheet from a jsp sheet wherein we can have a column as write protected???
 
Tim Moores
Bartender
Posts: 2686
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd start by finding out if Excel even supports this functionality; as I said, I'm not sure it does.
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:I'd start by finding out if Excel even supports this functionality; as I said, I'm not sure it does.


It does.

The functionality that TS is looking for is specified in the CellStyle interface. (http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/CellStyle.html).

The implementation of it is done in http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFCellStyle.html and there you can define a style and use the setLock(true) on the column by setting the columnStyle on the sheet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic