FileOutputStream fos
= null
;
SXSSFWorkbook sxssfWorkbook
= null
;
final String excelExportDestfilepath
= "C:/Users/sunbe/Desktop/abc.xlsx";
sxssfWorkbook
= new SXSSFWorkbook();
Sheet sheet
= sxssfWorkbook
.createSheet("我是Sheet");
Row header
= sheet
.createRow(0);
for (int rownum
= 0; rownum
<list
.size() ; rownum
++) {
Row row
= sheet
.createRow(rownum
);
int cellNum
;
for (int cellnum1
= 0; cellnum1
< cellNum
; cellnum1
++) {
ell cell
= row
.createCell(cellnum1
);
cell
.setCellValue((list
.get(rownum
- 1).getName()));
}
}
fos
= new FileOutputStream(excelExportDestfilepath
);
sxssfWorkbook
.write(fos
);
finally {
try {
if (sxssfWorkbook
!= null
) {
sxssfWorkbook
.dispose();
}
if (fos
!= null
) {
fos
.close();
}
} catch (IOException e
) {
e
.printStackTrace();
}
}
转载请注明原文地址:https://tech.qufami.com/read-22410.html