In this program we are going to shift the row using
Code description :
The packages we need to import are java.io.*, java.util.*, org.apache.poi.hssf.usermodel.HSSFSheet,org.apache.poi. hssf. usermodel. HSSFCellStyle, org.apache.poi.usermodel.HSSFRow, org.apache.poi.usermodel.HSSFCell and org.apache.poi.hssf.usermodel. HSSFWorkbook
In this example, we first create 50 cells and then insert 50 values, then we shift rows up. The starting row is 5 and end row is 10 and which will be shifted up 5 rows. Don't confuse by starting row 5 and end row 10. Because the row starts from 0 in excel file.
shiftRows(int startRow, int endRow, int n):
This method is used to shift the rows. There are three
arguments passed in this method. The first one is startRow. This is passed to
give the starting row and the
endRow is second argument. This is passed for end row up to we have shift.
Third one is int " n" which is used to define the number of rows will
be shift or we can say shifts rows between startRow and endRow n number of rows.
We can pass the third argument negative. The negative value mean shift rows up.
The code of the program is given below:
The output of the program is given below:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: May 19, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles