我正在使用apache poi库使用Java代码创建xlsx文件。 不是新要求,我需要创建具有大量数据的xlsx文件。所以我在考虑xlsb文件格式。但是我没有找到任何使用apache poi创建xlsb文件的方法。或任何其他将xlsx文件格式转换为xlsb文件的方法。 在这里,我要发布代码以使用apache poi创建xlsx文件
try {
outputFile = File.createTempFile("Dept_Wise_Invoice_Details-", ".xlsx");
OutputStream out = null;
out = new FileOutputStream(outputFile);
@SuppressWarnings("resource")
SXSSFWorkbook wb = new SXSSFWorkbook(2000);
SXSSFSheet sheet = wb.createSheet("Sheet1") ;
//iterating r number of rows
SXSSFRow header = sheet.createRow(0);
for (int c=0;c < model.getColumnCount()-2; c++ ) //-2
{
SXSSFCell cell = header.createCell(c);
cell.setCellValue(model.getColumnName(c).toString());
}
for (int r=0;r <row1.size() ; r++ )
{
SXSSFRow row = sheet.createRow(r+1);
//iterating c number of columns
for (int c=0;c < model.getColumnCount()-2; c++ ) //-2
{
SXSSFCell cell = row.createCell(c);
try
{
cell.setCellValue(model.getValueAt(Integer.parseInt(row1.get(r).toString()), c).toString());
}
catch(Exception eee)
{
//eee.printStackTrace();
cell.setCellValue("");
}
}
}
还是可以使用APATCHE POI创建XLSB文件?