/** * Shifts rows between startRow and endRow n number of rows. * If you use a negative number, it will shift rows up. * Code ensures that rows don't wrap around.<p> * * Calls {@code shiftRows(startRow, endRow, n, false, false);}<p> * * Additionally shifts merged regions that are completely defined in these * rows (ie. merged 2 cells on a row to be shifted). * * @param startRow the row to start shifting * @param endRow the row to end shifting * @param n the number of rows to shift */ @Override public void shiftRows(int startRow, int endRow, int n) { shiftRows(startRow, endRow, n, false, false); }
/** * Shifts rows between startRow and endRow n number of rows. * If you use a negative number, it will shift rows up. * Code ensures that rows don't wrap around<p> * * Additionally shifts merged regions that are completely defined in these * rows (ie. merged 2 cells on a row to be shifted). All merged regions that are * completely overlaid by shifting will be deleted.<p> * * TODO Might want to add bounds checking here * * @param startRow the row to start shifting * @param endRow the row to end shifting * @param n the number of rows to shift * @param copyRowHeight whether to copy the row height during the shift * @param resetOriginalRowHeight whether to set the original row's height to the default */ @Override public void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight) { shiftRows(startRow, endRow, n, copyRowHeight, resetOriginalRowHeight, true); }
/** * Remove a row by its index * @param sheet a Excel sheet * @param rowIndex a 0 based index of removing row */ public static void removeRow(HSSFSheet sheet, int rowIndex) { int lastRowNum=sheet.getLastRowNum(); if(rowIndex>=0&&rowIndex<lastRowNum){ sheet.shiftRows(rowIndex+1,lastRowNum, -1); } if(rowIndex==lastRowNum){ HSSFRow removingRow=sheet.getRow(rowIndex); if(removingRow!=null){ sheet.removeRow(removingRow); } } }
worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1); } else { newRow = worksheet.createRow(destinationRowNum);
/** * Shifts rows between startRow and endRow n number of rows. * If you use a negative number, it will shift rows up. * Code ensures that rows don't wrap around. * * Calls shiftRows(startRow, endRow, n, false, false); * * <p> * Additionally shifts merged regions that are completely defined in these * rows (ie. merged 2 cells on a row to be shifted). * @param startRow the row to start shifting * @param endRow the row to end shifting * @param n the number of rows to shift */ public void shiftRows( int startRow, int endRow, int n ) { shiftRows(startRow, endRow, n, false, false); }
/** * Shifts rows between startRow and endRow n number of rows. * If you use a negative number, it will shift rows up. * Code ensures that rows don't wrap around. * <p/> * Calls shiftRows(startRow, endRow, n, false, false); * <p/> * <p/> * Additionally shifts merged regions that are completely defined in these * rows (ie. merged 2 cells on a row to be shifted). * * @param startRow the row to start shifting * @param endRow the row to end shifting * @param n the number of rows to shift */ public void shiftRows(int startRow, int endRow, int n) { shiftRows(startRow, endRow, n, false, false); }
/** * Shifts rows between startRow and endRow n number of rows. * If you use a negative number, it will shift rows up. * Code ensures that rows don't wrap around * * <p> * Additionally shifts merged regions that are completely defined in these * rows (ie. merged 2 cells on a row to be shifted). * <p> * TODO Might want to add bounds checking here * @param startRow the row to start shifting * @param endRow the row to end shifting * @param n the number of rows to shift * @param copyRowHeight whether to copy the row height during the shift * @param resetOriginalRowHeight whether to set the original row's height to the default */ public void shiftRows( int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight) { shiftRows(startRow, endRow, n, copyRowHeight, resetOriginalRowHeight, true); }
/** * Shifts rows between startRow and endRow n number of rows. * If you use a negative number, it will shift rows up. * Code ensures that rows don't wrap around * <p/> * <p/> * Additionally shifts merged regions that are completely defined in these * rows (ie. merged 2 cells on a row to be shifted). * <p/> * TODO Might want to add bounds checking here * * @param startRow the row to start shifting * @param endRow the row to end shifting * @param n the number of rows to shift * @param copyRowHeight whether to copy the row height during the shift * @param resetOriginalRowHeight whether to set the original row's height to the default */ public void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight) { shiftRows(startRow, endRow, n, copyRowHeight, resetOriginalRowHeight, true); }
/** * Shifts rows between startRow and endRow n number of rows. * If you use a negative number, it will shift rows up. * Code ensures that rows don't wrap around.<p> * * Calls {@code shiftRows(startRow, endRow, n, false, false);}<p> * * Additionally shifts merged regions that are completely defined in these * rows (ie. merged 2 cells on a row to be shifted). * * @param startRow the row to start shifting * @param endRow the row to end shifting * @param n the number of rows to shift */ @Override public void shiftRows(int startRow, int endRow, int n) { shiftRows(startRow, endRow, n, false, false); }
/** * Shifts rows between startRow and endRow n number of rows. * If you use a negative number, it will shift rows up. * Code ensures that rows don't wrap around<p> * * Additionally shifts merged regions that are completely defined in these * rows (ie. merged 2 cells on a row to be shifted). All merged regions that are * completely overlaid by shifting will be deleted.<p> * * TODO Might want to add bounds checking here * * @param startRow the row to start shifting * @param endRow the row to end shifting * @param n the number of rows to shift * @param copyRowHeight whether to copy the row height during the shift * @param resetOriginalRowHeight whether to set the original row's height to the default */ @Override public void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight) { shiftRows(startRow, endRow, n, copyRowHeight, resetOriginalRowHeight, true); }
File file = new File(....); FileInputStream fis = new FileInputStream(file); HSSFWorkbook wb = new HSSFWorkbook(fis); HSSFSheet sheet = wb.getSheetAt(0); sheet.shiftRows(3, 3, -1); File outWB = new File(.....); OutputStream out = new FileOutputStream(outWB); wb.write(out); out.flush(); out.close();
public static void removeRow(HSSFSheet sheet, int rowIndex) { int lastRowNum=sheet.getLastRowNum(); if(rowIndex>=0&&rowIndex<lastRowNum){ sheet.shiftRows(rowIndex+1,lastRowNum, -1); } if(rowIndex==lastRowNum){ HSSFRow removingRow=sheet.getRow(rowIndex); if(removingRow!=null){ sheet.removeRow(removingRow); } } }
HSSFSheet hoja = wb.getSheetAt(0); HSSFRow fila = hoja.getRow(numFila); hoja.removeRow(fila); hoja.shiftRows(numFila+1, hoja.getLastRowNum(), -1);
/** * Remove a row by its index * @param sheet a Excel sheet * @param rowIndex a 0 based index of removing row */ public static void removeRow(HSSFSheet sheet, int rowIndex) { int lastRowNum=sheet.getLastRowNum(); if(rowIndex>=0&&rowIndex<lastRowNum){ sheet.shiftRows(rowIndex+1,lastRowNum, -1); } if(rowIndex==lastRowNum){ HSSFRow removingRow=sheet.getRow(rowIndex); if(removingRow!=null){ sheet.removeRow(removingRow); } } }
sheet.shiftRows(row_count_post_1 + 1, lastIndex, -1); } else { break InnerLoop; // OR break OuterLoop;
sheet.shiftRows(row_count_post_1 + 1, lastIndex, -1); } else { stop = true;
worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1); } else { newRow = worksheet.createRow(destinationRowNum);
worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1); } else { newRow = worksheet.createRow(destinationRowNum);