我是靠谱客的博主 闪闪灰狼,这篇文章主要介绍java excel 插入新行_POI ,Java 操作 Excel 實現行的插入(insert row),现在分享给大家,希望可以做个参考。

POI ,Java 操作 Excel 實現行的插入(insert row)

前幾天,正在做一個項目,主要用 POI 來操作 Excel

其中,要使用一個,插入功能。主要是因為從數據庫,返回結果集(數據明細),來動態車生成新行,插入明細

在網上找了找,沒有找到,好的方法

自己寫了一個:

public static void insertRow(HSSFWorkbook wb, HSSFSheet sheet, int starRow,int rows) {

sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows,true,false);

//  Parameters:

//   startRow - the row to start shifting

//   endRow - the row to end shifting

//   n - the number of rows to shift

//   copyRowHeight - whether to copy the row height during the shift

//   resetOriginalRowHeight - whether to set the original row's height to the default

starRow = starRow - 1;

for (int i = 0; i < rows; i++) {

HSSFRow sourceRow = null;

HSSFRow targetRow = nul

最后

以上就是闪闪灰狼最近收集整理的关于java excel 插入新行_POI ,Java 操作 Excel 實現行的插入(insert row)的全部内容,更多相关java内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部