Please do not take this as the definitive example of locking using XSSF. That
was simply a small piece of code that I was playing around with because at
that time no one seemed to know just whatthe sequence of method calls had to
be in order to protect the contents of an Excel workbook built using XSSF.
It may well be that you need to call other methods than these and I have not
undertaken any testing to see what they do so cannot really comment further
on this matter. I do wonder though if you are focusing on the wrong aspect
of the problem.

If I understand what you said correctly, you have a worksheet that you wish
to protect, preventing users even from changing the widths of the columns.
Occaisionally, you encounter a problem when the values you have to write
into certain cells are so long, they stretch past the edges of the cell and
are hidden from view unless the user CAN increase the width of the column.
Well, if that is the case, I think that you should really consider
formatting those cells and structuring their contents so that they can be
seen without the need to expand the columns. POI includes a method that you
can call to size the column so that it accomodates the largest (in terms of
it's width) value. Alternatively, you could simply insert line breaks (\n)
into the cells contents at strategic points and then set word wrapping on
for the cell. You may also need to adjust the height of the row in this case
although Excel may - MAY - set this for you automatically when the sheet is
opened.

Yours

Mark B


ragz_82 wrote:
> 
> Mark,
> I am facing a similar situation. My requirement is to basically make the
> generated .xlsx file as read only. The enableLocking method almost
> achieves this functionality, but there are two shortfalls.
> 
> 1. In cases where the cell content is longer than usual, I am unable to
> stretch the column width to view the cell content completely. This defeats
> the purpose of the Report.
> 2. Clicking the Unprotect Worksheet button under the Review tab, revokes
> this entire setting. In other words, the sheet is editable.
> 
> Please let me know if you have any suggestions.
> 
> Regards,
> Raghu
> 
> 

-- 
View this message in context: 
http://old.nabble.com/POI-XSSF-API-how-do-I-lock-specific-Excel-sheet-features--tp27332341p28457266.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@poi.apache.org
For additional commands, e-mail: user-h...@poi.apache.org

Reply via email to