我是靠谱客的博主 有魅力书包,这篇文章主要介绍java excel 插入新行_使用POI往EXCEL中插入行,现在分享给大家,希望可以做个参考。

部分代码如下(POI的版本为3.2)

public void insertRow() throws IOException {

POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("workbook.xls"));

HSSFWorkbook wb = new HSSFWorkbook(fs);

HSSFSheet sheet = wb.getSheet("new sheet");

int starRow = 4;

int rows = 5;

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 = null;

HSSFCell

最后

以上就是有魅力书包最近收集整理的关于java excel 插入新行_使用POI往EXCEL中插入行的全部内容,更多相关java内容请搜索靠谱客的其他文章。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部