You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "H@rry" <ap...@SoftHome.net> on 2003/03/06 07:21:28 UTC
Unlock cells become locked after writing
Hi,
I have a template pre-created....
There are some cells in the sheet that are locked and the sheet is
protected.
After reading the template, I add the some data and write to a file.
The generated Excel File now have some cells (Which I wrote data onto using
POI are oso locked)!
Here is the code which I will call to write data into the cell :-
private static void writeCell(int datatype, String data, HSSFCell cell)
{
try {
switch(datatype)
{
case 2 : //Boolean
cell.setCellType(HSSFCell.CELL_TYPE_BOOLEAN);
cell.setCellValue(Boolean.valueOf(data).booleanValue());
return;
case 3 : //Number
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cell.setCellValue(Double.parseDouble(data));
return;
case 4 : //Date
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cell.setCellValue(new java.util.Date(data));
return;
case 1 : //String
}
}
catch (Exception e) { } //catch error above datatype...will set
normal string
//others datatype created will be returned before this...
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(data);
}
Wonder wat's wrong here....
"I know that the world is always unfair.
But I don't understand why it is never unfair to my advantage."
@harry
Re: Unlock cells become locked after writing
Posted by Glen Stampoultzis <gs...@iinet.net.au>.
Protected is not supported (it's in the FAQ I think).
At 05:21 PM 6/03/2003, you wrote:
>Hi,
>I have a template pre-created....
>There are some cells in the sheet that are locked and the sheet is
>protected.
>
>
>After reading the template, I add the some data and write to a file.
>The generated Excel File now have some cells (Which I wrote data onto using
>POI are oso locked)!
>
>Here is the code which I will call to write data into the cell :-
> private static void writeCell(int datatype, String data, HSSFCell cell)
> {
> try {
> switch(datatype)
> {
> case 2 : //Boolean
> cell.setCellType(HSSFCell.CELL_TYPE_BOOLEAN);
> cell.setCellValue(Boolean.valueOf(data).booleanValue());
> return;
> case 3 : //Number
> cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
> cell.setCellValue(Double.parseDouble(data));
> return;
> case 4 : //Date
> cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
> cell.setCellValue(new java.util.Date(data));
> return;
> case 1 : //String
> }
> }
> catch (Exception e) { } //catch error above datatype...will set
>normal string
> //others datatype created will be returned before this...
> cell.setCellType(HSSFCell.CELL_TYPE_STRING);
> cell.setCellValue(data);
> }
>
>Wonder wat's wrong here....
>
>"I know that the world is always unfair.
> But I don't understand why it is never unfair to my advantage."
>
>
>@harry
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: poi-user-help@jakarta.apache.org