Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.poi.ss.util
Class SheetBuilder

    java.lang.Object
      org.apache.poi.ss.util.SheetBuilder

    public class SheetBuilder

extends java.lang.Object

Class `SheetBuilder` provides an easy way of building workbook sheets from 2D array of Objects. It can be used in test cases to improve code readability or in Swing applications with tables.

Author:
  Roman Kashitsyn

Constructor Summary
`SheetBuilder(Workbook workbook, java.lang.Object[][] cells)`

Method Summary
`Sheet` | `build()` Builds sheet from parent workbook and 2D array with cell values.
`boolean` | `getCreateEmptyCells()` Returns `true` if null array elements should be treated as empty cells.
`SheetBuilder` | `setCreateEmptyCells(boolean shouldCreateEmptyCells)` Specifies if null array elements should be treated as empty cells.
`SheetBuilder` | `setSheetName(java.lang.String sheetName)` Specifies name of the sheet to build.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SheetBuilder

    public SheetBuilder(Workbook workbook,
                        java.lang.Object[][] cells)

Method Detail

### getCreateEmptyCells

    public boolean getCreateEmptyCells()

  Returns `true` if null array elements should be treated as empty cells.

  Returns:
    `true` if null objects should be treated as empty cells and `false` otherwise

### setCreateEmptyCells

    public SheetBuilder setCreateEmptyCells(boolean shouldCreateEmptyCells)

  Specifies if null array elements should be treated as empty cells.

  Parameters:
    `shouldCreateEmptyCells` - `true` if null array elements should be treated as empty cells
  Returns:
    `this`

### setSheetName

    public SheetBuilder setSheetName(java.lang.String sheetName)

  Specifies name of the sheet to build. If not specified, default name (provided by workbook) will be used instead.

  Parameters:
    `sheetName` - sheet name to use
  Returns:
    `this`

### build

    public Sheet build()

  Builds sheet from parent workbook and 2D array with cell values. Creates rows anyway (even if row contains only null cells), creates cells if either corresponding array value is not null or createEmptyCells property is true. The conversion is performed in the following way:

  - Numbers become numeric cells.
  - `java.util.Date` or `java.util.Calendar` instances become date cells.
  - String with leading '=' char become formulas (leading '=' will be truncated).
  - Other objects become strings via `Object.toString()` method call.

  Returns:
    newly created sheet

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2017 The Apache Software Foundation or its licensors, as applicable.