Hi,

 

I'm having the following weird problem.  Can anyone help me please?

 

I've 10 rows in my xls.

 

I add new rows programmatically using the following little add new row method that I 
wrote.

 

Say, I added one new row after the second row.

If I say, sh.getRow(9), I get the 9th row, which is correct because, there is a new 
row added.

 

When I try to read the 10th row ( HSSFRow row = sh.getRow(9); ), here the row is null. 
 Any help is appreciated please.

 

    /**
     * inserts a new row in the spreadsheet
     * @param sh
     * @param newRowNumber
     */
    public static final HSSFRow addNewRow(HSSFSheet sh, int newRowNumber)
    {
        // shift the cells down and make room to add new row
        sh.shiftRows(newRowNumber, sh.getLastRowNum(), 1);

 

        HSSFRow newRow = sh.createRow(newRowNumber);
        HSSFCell         c      = null;

 

        for (short cellnum = ( short ) 0; cellnum < 25; cellnum++) {
            c = newRow.createCell(cellnum, HSSFCell.CELL_TYPE_STRING);
            c.setCellValue("");
        }

 

        return newRow;
    }

 

Thanks in advance,

Naga

 

                
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!

Reply via email to