Lines 829-832
Link Here
|
829 |
public void setMargin(short margin, double size) { |
829 |
public void setMargin(short margin, double size) { |
830 |
getSheet().setMargin(margin, size); |
830 |
getSheet().setMargin(margin, size); |
831 |
} |
831 |
} |
|
|
832 |
|
833 |
/** |
834 |
* Shifts rows between startRow and endRow n number of rows. |
835 |
* If you use a negative number, it will shift rows up. |
836 |
* |
837 |
* @param startRow the row to start shifting |
838 |
* @param endRow the row to end shifting |
839 |
* @param n the number of rows to shift |
840 |
*/ |
841 |
public void shiftRows(int startRow, int endRow, int n) { |
842 |
int s, e, inc; |
843 |
if (n < 0) { |
844 |
s = startRow; |
845 |
e = endRow; |
846 |
inc = 1; |
847 |
} else { |
848 |
s = endRow; |
849 |
e = startRow; |
850 |
inc = -1; |
851 |
} |
852 |
for (int rowNum = s; rowNum >= startRow && rowNum <= endRow; rowNum+=inc) { |
853 |
System.out.println(rowNum); |
854 |
HSSFRow row = getRow(rowNum); |
855 |
HSSFRow row2Replace = getRow(rowNum + n); |
856 |
if (row2Replace != null) { |
857 |
removeRow(row2Replace); |
858 |
} |
859 |
if (row != null) { |
860 |
System.out.println("Shifting " + rowNum); |
861 |
row.setRowNum(rowNum + n); |
862 |
System.out.println(row.getPhysicalNumberOfCells()); |
863 |
} |
864 |
} |
865 |
if (endRow + n > lastrow) lastrow = endRow + n; |
866 |
if (startRow + n > firstrow) firstrow = startRow + n; |
867 |
System.out.println(firstrow + " " + lastrow); |
868 |
} |
832 |
} |
869 |
} |