首页 > 其他 > 详细

POI 导出文档整理

时间:2018-06-23 17:58:34      阅读:141      评论:0      收藏:0      [点我收藏+]

1 通过模板获取workbook

public static Workbook getWorkBook(String templatePath) {
try {
InputStream in = new FileInputStream(templatePath);
return new HSSFWorkbook(in);
} catch (IOException e) {
L.printException(e);
return null;
}
}

mSheet = workBook.getSheetAt(i);

 

2 sheet  row

public static Row getCreateRow(Sheet sheet, int rowIndex) {
Row rowNew = sheet.getRow(rowIndex);
if (rowNew == null) {
rowNew = sheet.createRow(rowIndex);
}
return rowNew;
}

3 row -->cell

private static Cell getCreateCell(@NonNull Row rowNew, int m) {
Cell cell = rowNew.getCell(m);
if (cell == null) {
cell = rowNew.createCell(m);
}
return cell;
}

5cell- value

public static int fillCell(Row rowNew, int m, String value) {
Cell cell = getCreateCell(rowNew, m);
cell.setCellValue(value);
m++;
return m;
}

 

POI 导出文档整理

原文:https://www.cnblogs.com/spps/p/9217683.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!