码迷,mamicode.com
首页 > 其他好文 > 详细

POI 导出文档整理

时间:2018-06-23 19:08:17      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:获取   static   gets   stream   LLC   ++   val   tst   catch   

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 导出文档整理

标签:获取   static   gets   stream   LLC   ++   val   tst   catch   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!