poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "H@rry" <apache...@SoftHome.net>
Subject Unlock cells become locked after writing
Date Thu, 06 Mar 2003 06:21:28 GMT
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



Mime
View raw message