注意此例需要jxls的支持
:
/**
* insert row into the target sheet, the style of cell is the same as startRow
* @param wb
* @param sheet
* @param starRow - the row to start shifting
* @param rows
*/
public static void insertRow(HSSFWorkbook wb, HSSFSheet sheet, int startRow,int rows) {
sheet.shiftRows(startRow + 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
for (int i = 0; i < rows; i++) {
HSSFRow sourceRow = null;
HSSFRow targetRow = null;
sourceRow = sheet.getRow(startRow);
targetRow = sheet.createRow(++startRow);
Util.copyRow(sheet, sourceRow, targetRow);
}
}
插入行会继承第“startRow”行的样式,实际上就是拷贝“startRow”,甚至包括合并的单元格
参考了http://blog.csdn.net/daemon_boy/archive/2007/09/15/1786384.aspx的代码
分享到:
相关推荐
POI向excel中插入图片
poi excel poi excel poi excel poi excel poi excel poi excel poi excel poi excel
poi 操作excel模板,读取数据后,讲数据填充到新生成的文件中且提供下载
java_poi实现excel导入导出功能,有详细的注解
POI生成Excel POI读取Excel java操作Excel Servlet生成Excel web项目,包含含读取Excel与生成Excel方法
用poi实现的excel导入导出,进行了很好的封装
POI对Word的操作,特别是针对生成报告模板时,向word中写入文本和图片。
基于SpringBoot和POI实现单线程和多线程导出Excel.zip基于SpringBoot和POI实现单线程和多线程导出Excel.zip基于SpringBoot和POI实现单线程和多线程导出Excel.zip基于SpringBoot和POI实现单线程和多线程导出Excel.zip...
Java代码对Excel进行增,删,改。及样式
JAVA操作excel poi poi.jarJAVA操作excel poi poi.jarJAVA操作excel poi poi.jarJAVA操作excel poi poi.jar
poi3.0.1操作excel,包括新增,修改excel的操作
POI操作excel表格 讲的很详细,很有用
通过反射和相应的约定实现POI操作Excel的封装
Poi 写入EXCEL 插入一行Poi 写入EXCEL 插入一行
该资源主要实现如下功能,利用poi获取excel中大量数据,然后利用jdbc批量插入到mysql
为更方便的使用POI的API来操作Excel(2003)文件,对POI中针对Excel文件的读写进行了简单封装。此类中包含以下功能: 1.根据模板创建Excel文件 ...压缩包中包含POI的jar文件、POIExcel的jar文件及POIExcel的源码
java实现word、excel在线预览。版本2003和2007都支持在线预览,项目需要导入一些poi相关的jar,jar之间的版本有要求。在我的资源列表,有相关的jar包可以下载。
利用POI实现Excel的导入和导出实例的实现,外加poi的全部jar包
java实现excel的导入导出(poi详解),经过测试poi效率要比jxl要高很多,特别是数据量大的时候jxl根本无法用肉眼入目,本资源是个可运行项目demo,很有参考价值!
1.java使用poi生成excel插入图表曲线 2.demo包含完成jar包 3.主要用途是过滤数据自动生成曲线图