org.apache.poi.hssf.usermodel.HSSFSheet.shiftRows()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中org.apache.poi.hssf.usermodel.HSSFSheet.shiftRows()方法的一些代码示例,展示了HSSFSheet.shiftRows()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFSheet.shiftRows()方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFSheet
类名称:HSSFSheet
方法名:shiftRows

HSSFSheet.shiftRows介绍

[英]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);

Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted).
[中]在开始行和结束行之间移动行数n行。如果使用负数,它会将行上移。代码确保行不会环绕。调用shiftRows(startRow、endRow、n、false、false);
另外,移动在这些行中完全定义的合并区域(即,要移动的行上合并的2个单元格)。

代码示例

代码示例来源:origin: org.apache.poi/poi

/**
 * 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);
}

代码示例来源:origin: org.apache.poi/poi

/**
 * 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);
}

代码示例来源:origin: stackoverflow.com

/**
 * 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);
    }
  }
}

代码示例来源:origin: stackoverflow.com

worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1);
} else {
  newRow = worksheet.createRow(destinationRowNum);

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * 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);
}

代码示例来源:origin: com.haulmont.thirdparty/poi

/**
 * 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);
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * 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);
}

代码示例来源:origin: com.haulmont.thirdparty/poi

/**
 * 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);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * 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);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * 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);
}

代码示例来源:origin: stackoverflow.com

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();

代码示例来源:origin: stackoverflow.com

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);
    }
  }
}

代码示例来源:origin: stackoverflow.com

HSSFSheet hoja = wb.getSheetAt(0);
HSSFRow fila = hoja.getRow(numFila);
hoja.removeRow(fila);
hoja.shiftRows(numFila+1, hoja.getLastRowNum(), -1);

代码示例来源:origin: stackoverflow.com

/**
* 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);
     }
   }
 }

代码示例来源:origin: stackoverflow.com

sheet.shiftRows(row_count_post_1 + 1, lastIndex, -1);
} else {
  break InnerLoop; // OR break OuterLoop;

代码示例来源:origin: stackoverflow.com

sheet.shiftRows(row_count_post_1 + 1, lastIndex, -1);
} else {
  stop = true;

代码示例来源:origin: stackoverflow.com

worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1);
} else {
  newRow = worksheet.createRow(destinationRowNum);

代码示例来源:origin: micromata/projectforge

worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1);
} else {
 newRow = worksheet.createRow(destinationRowNum);

相关文章

微信公众号

最新文章

更多

HSSFSheet类方法