views:

20

answers:

1

Hi to all,

I am using apache poi 3.6 and java in our application.

i have data in row numbers 9 to 30.

Now, i want to include new rows after the row number 25.after doing like this,the old data in 26 to 30 was destroyed....i want to add that new rows without destroy the old row's data...

we can manually, create new rows by just right click the mouse on the row Header like row number 25 and select insert then it will include the 26 row without deleting anything abt the old values.

how i do it programatically using apache poi and java...

Plz tell me the solution...

advance thanks to all

A: 

First you need to do move down all the rows from 25 onwards by doing a shift

sheet1.shiftRows(25, sheet1.getLastRowNum(), 5);

this will move down all rows from 25 by 5 places

then insert the new rows in that position

row1 = sheet1.getRow(25); 
                HSSFCell cell1 = row1.createCell(0);
                cell1.setCellValue("text: The new line goes here");
JoseK