poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anand,Anuj" <Anuj.An...@CNA.com>
Subject RE: copy Cell Style
Date Mon, 07 Jul 2003 20:17:14 GMT
Just had a small question.
I am actually reading an excel file on the server using POI. Do I need excel
to be installed on that server?

Thanks,
ANuj

 

-----Original Message-----
From: Andrej Golovnin [mailto:golovnin@gmx.net] 
Sent: Thursday, April 24, 2003 7:27 AM
To: POI Users List
Subject: Re: copy Cell Style


Hi mike,

Your method seems to be Ok. I'm using a similar method to copy a cell with
style and value 
but only in the same sheet and every thing works fine.

Here is my method, hope this will help:

    /** Copies the specified cell to a new location in the specified sheet.
     * It will copies both the value and format of the cell.
     * @param sheet the sheet to be used for copying.
     * @param cell the cell to be copied.
     * @param dstRow the row where the cell is placed.
     * @param dstColumn the column where the cell is placed.
     */
    private void copyCell(final HSSFSheet sheet, final HSSFCell cell, final
int dstRow, final int dstColumn) {
        HSSFRow row = sheet.getRow(dstRow);
        if ( row == null ) {
            row = sheet.createRow((short)dstRow);
        }
        HSSFCell dstCell = row.getCell((short)dstColumn);
        if ( dstCell == null ) {
            dstCell = row.createCell((short)dstColumn);
        }
        dstCell.setCellStyle(cell.getCellStyle());
        switch( cell.getCellType() ) {
            case HSSFCell.CELL_TYPE_BOOLEAN:
                dstCell.setCellValue(cell.getBooleanCellValue());
                break;
            case HSSFCell.CELL_TYPE_ERROR:
                dstCell.setCellErrorValue(cell.getErrorCellValue());
                break;
            case HSSFCell.CELL_TYPE_NUMERIC:
                dstCell.setCellValue(cell.getNumericCellValue());
                break;
            case HSSFCell.CELL_TYPE_STRING:
                dstCell.setCellValue(cell.getStringCellValue());
                break;
        }
        dstCell.setEncoding(cell.getEncoding());
    }

Regards,

Andrej Golovnin


-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte l├Ącheln! Fotogalerie online mit GMX ohne eigene Homepage!


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

Mime
View raw message