Example usage for org.apache.poi.xssf.streaming SXSSFWorkbook getNumberOfSheets

List of usage examples for org.apache.poi.xssf.streaming SXSSFWorkbook getNumberOfSheets

Introduction

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

Prototype

@Override
public int getNumberOfSheets() 

Source Link

Document

Get the number of spreadsheets in the workbook

Usage

From source file:org.riflemansd.businessprofit.excel.ExcelExamplePOI.java

License:Open Source License

public static void main(String[] args) throws Throwable {
    SXSSFWorkbook wb = new SXSSFWorkbook(1000); // keep 100 rows in memory, exceeding rows will be flushed to disk

    if (wb.getNumberOfSheets() == 0) {
        wb.createSheet("MySheet");
    }/*from  w  w w.j a v a  2 s .  c  o  m*/
    Sheet sh = wb.getSheetAt(0);
    Row row = sh.createRow(3);

    for (int i = 0; i < 10; i++) {
        Cell cell = row.createCell(i);
        //String address = new CellReference(cell).formatAsString();
        cell.setCellValue("? " + i);
        //row.setHeightInPoints(50);
        //sh.setColumnWidth(5, 1200); //4, 33 pixels
        wb.getSheetAt(0).autoSizeColumn(i);
    }

    FileOutputStream out = new FileOutputStream("test.xlsx");
    wb.write(out);
    out.close();

    // dispose of temporary files backing this workbook on disk
    wb.dispose();

    Desktop.getDesktop().open(new File("test.xlsx"));
}