POI 导出文档整理
Posted spps
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了POI 导出文档整理相关的知识,希望对你有一定的参考价值。
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 导出文档整理的主要内容,如果未能解决你的问题,请参考以下文章