我正在尝试将 excel 工作簿写入文件。使用 Apache POI。我调试并发现我的工作簿有数据。一旦我将此工作簿写入 FileOutputStream,它就会成功写入而没有任何错误。但生成的文件中没有任何内容。那是一个空白文件。这是我编写文件的代码:
public void generateOutputSheet(String outputPath)
{
try
{
HSSFWorkbook outputWrkBook = mapBuilder.BuildOutputWorkBook(); // this have two sheets and each sheet have data
//( one has 800 rows and another 6000 rows , i verified
FileOutputStream outputFilestream = new FileOutputStream(outputPath);
outputWrkBook.write(outputFilestream);
outputFilestream.flush();
outputFilestream.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
System.out.println("the output file is available at location:"+outputPath);
}