Example usage for org.apache.poi.xssf.streaming SXSSFSheet flushRows

List of usage examples for org.apache.poi.xssf.streaming SXSSFSheet flushRows

Introduction

In this page you can find the example usage for org.apache.poi.xssf.streaming SXSSFSheet flushRows.

Prototype

public void flushRows() throws IOException 

Source Link

Document

Flush all rows to disk.

Usage

From source file:com.github.igor_kudryashov.utils.excel.ExcelWriter.java

License:Apache License

/**
 * Save a workbook in file//from   www .j  a va 2  s . c  om
 *
 * @param fileName
 *            filename
 * @return <code>true</code> if saved successfully, otherwise
 *         <code>false</code>
 * @throws IOException
 */
public boolean saveToFile(String fileName) throws IOException {
    for (int x = 0; x < workbook.getNumberOfSheets(); x++) {
        SXSSFSheet sheet = workbook.getSheetAt(x);
        sheet.flushRows();
    }
    // Write the output to a file
    FileOutputStream fileOut = new FileOutputStream(fileName);
    workbook.write(fileOut);
    fileOut.close();
    // dispose of temporary files backing this workbook on disk
    workbook.dispose();
    return (true);
}