POI ,Java 操作 Excel 实现行的插入(insert row)
来源:互联网 发布:大数据技术入门书籍 编辑:程序博客网 时间:2024/05/11 16:55
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 = null;
HSSFCell sourceCell = null;
HSSFCell targetCell = null;
short m;
starRow = starRow + 1;
sourceRow = sheet.getRow(starRow);
targetRow = sheet.createRow(starRow + 1);
targetRow.setHeight(sourceRow.getHeight());
for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) {
sourceCell = sourceRow.getCell(m);
targetCell = targetRow.createCell(m);
targetCell.setEncoding(sourceCell.getEncoding());
targetCell.setCellStyle(sourceCell.getCellStyle());
targetCell.setCellType(sourceCell.getCellType());
}
}
}
- POI ,Java 操作 Excel 实现行的插入(insert row)
- POI ,Java 操作 Excel 实现行的插入(insert row)
- JAVA实现在excel插入图片(POI模式)
- JAVA的POI操作Excel
- java:Excel操作(poi)
- Java POI Excel( poi:纯java操作excel的api )
- 利用POI实现JAVA操作EXCEL表
- Java 操作 Excel (读取Excel2007,Poi实现)
- Java 操作 Excel (读取Excel2007,Poi实现)
- Java 操作 Excel (读取Excel2007,Poi实现)
- Java 操作 Excel (读取Excel2007,Poi实现)
- JAVA基于poi实现操作Excel
- Struts2+poi实现Excel文件上传并插入数据库的操作
- java (apache POI 组件) 操作 excel 插入批注
- POI实现Excel插入图片
- Java操作Excel Poi
- Java操作Excel Poi
- POI Java操作Excel
- 排序算法3--插入排序
- Solution Manager 中的角色概览
- PDF屏蔽打印,隐藏工具栏和菜单栏
- C# 通用上传文件类
- 龙脉精灵多开脚本
- POI ,Java 操作 Excel 实现行的插入(insert row)
- Guide to Software Testing and Quality Assurance
- Java入门需掌握的30个基本概念
- 计算题
- SAP Solution Manager用户权限及角色的调整
- 我的INTERNET网络收藏夹网址
- asp网页提升速度方法5则
- asp之数学函数
- Java中的接口及抽象类