2016-08-22 10 views

回答

1

從以下方面:https://poi.apache.org/spreadsheet/quick-guide.html

您可以使用使用FileOutput流和工作簿寫它保存到一個xls文件。

Workbook wb = new HSSFWorkbook(); //declare a workbook. 

//operations on wb.... create sheets, modify cells. 

FileOutputStream fos = new FileOutputStream("my_workbook.xls"); //create the output stream to write to. (this is the name of the file you are going to be writing to. 
wb.write(fos); //Write the workbook to the output stream. 
fos.close(); //IMPORTANT, close the output stream. 

我會閱讀很多我鏈接的文章,因爲它包含很多對Apache POI的引用並且是一個很好的閱讀。

我將宣佈對儲蓄的方法,通過在工作簿和文件名或類似的東西,比如如下:

public void saveWorkbook(Workbook workbook, String saveFileName) throws FileNotFoundException 
{ 
    //Try with resources, if using Java 7+, otherwise you have to close fileOut manually. 
    try(FileOutputStream fileOut = new FileOutputStream(saveFileName)) 
    { 
     workbook.write(fileOut); 
    } 
} 

這將確保你關閉你的流每次一個好辦法,而且只是良好的做法。

+0

其實我的要求是閱讀現場流媒體表,我還沒有找到任何參考,請分享知識,如果你有任何。 –

+0

@KsrimuralikrishnaKsrimuralikr你可以保存工作表,然後從保存的xls文檔讀取,或者不是你想怎麼做? – Orin

+0

認爲是一個直播流表然後如何保存這種文件的編程方式? –

相關問題