这个是更新excel中的扩展为xls文件的修改
This commit is contained in:
parent
47cce5d933
commit
819a35ac24
@ -91,18 +91,22 @@ public class HSSFUtils {
|
||||
mergeSheetAllRegion(tmpSheet, newExcelSheet);
|
||||
// 设置单元格列宽度
|
||||
// 获取最后一个单元格位置
|
||||
int len = tmpSheet.getRow(tmpSheet.getFirstRowNum()).getLastCellNum();
|
||||
for (int i = 0; i < len; i++) {
|
||||
newExcelSheet.setColumnWidth(i, tmpSheet.getColumnWidth(i));
|
||||
}
|
||||
// 复制每行内容
|
||||
Iterator<Row> it = tmpSheet.iterator();
|
||||
while (it.hasNext()) {
|
||||
HSSFRow tmpRow = (HSSFRow) it.next();
|
||||
// 创建新行
|
||||
HSSFRow newExcelRow = newExcelSheet.createRow(tmpRow.getRowNum());
|
||||
// 复制行
|
||||
copyExcelRow(workbook, tmpRow, newExcelRow);
|
||||
if (tmpSheet.getRow(tmpSheet.getFirstRowNum())==null){
|
||||
|
||||
}else {
|
||||
int len = tmpSheet.getRow(tmpSheet.getFirstRowNum()).getLastCellNum();
|
||||
for (int i = 0; i < len; i++) {
|
||||
newExcelSheet.setColumnWidth(i, tmpSheet.getColumnWidth(i));
|
||||
}
|
||||
// 复制每行内容
|
||||
Iterator<Row> it = tmpSheet.iterator();
|
||||
while (it.hasNext()) {
|
||||
HSSFRow tmpRow = (HSSFRow) it.next();
|
||||
// 创建新行
|
||||
HSSFRow newExcelRow = newExcelSheet.createRow(tmpRow.getRowNum());
|
||||
// 复制行
|
||||
copyExcelRow(workbook, tmpRow, newExcelRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -91,18 +91,22 @@ public class Utils {
|
||||
mergeSheetAllRegion(tmpSheet, newExcelSheet);
|
||||
// 设置单元格列宽度
|
||||
// 获取最后一个单元格位置
|
||||
int len = tmpSheet.getRow(tmpSheet.getFirstRowNum()).getLastCellNum();
|
||||
for (int i = 0; i < len; i++) {
|
||||
newExcelSheet.setColumnWidth(i, tmpSheet.getColumnWidth(i));
|
||||
}
|
||||
// 复制每行内容
|
||||
Iterator<Row> it = tmpSheet.iterator();
|
||||
while (it.hasNext()) {
|
||||
XSSFRow tmpRow = (XSSFRow) it.next();
|
||||
// 创建新行
|
||||
XSSFRow newExcelRow = newExcelSheet.createRow(tmpRow.getRowNum());
|
||||
// 复制行
|
||||
copyExcelRow(workbook, tmpRow, newExcelRow);
|
||||
if (tmpSheet.getRow(tmpSheet.getFirstRowNum())==null){
|
||||
|
||||
}else {
|
||||
int len = tmpSheet.getRow(tmpSheet.getFirstRowNum()).getLastCellNum();
|
||||
for (int i = 0; i < len; i++) {
|
||||
newExcelSheet.setColumnWidth(i, tmpSheet.getColumnWidth(i));
|
||||
}
|
||||
// 复制每行内容
|
||||
Iterator<Row> it = tmpSheet.iterator();
|
||||
while (it.hasNext()) {
|
||||
XSSFRow tmpRow = (XSSFRow) it.next();
|
||||
// 创建新行
|
||||
XSSFRow newExcelRow = newExcelSheet.createRow(tmpRow.getRowNum());
|
||||
// 复制行
|
||||
copyExcelRow(workbook, tmpRow, newExcelRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user