Example usage for org.apache.poi.ss.usermodel Sheet getDefaultRowHeightInPoints

List of usage examples for org.apache.poi.ss.usermodel Sheet getDefaultRowHeightInPoints

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Sheet getDefaultRowHeightInPoints.

Prototype

float getDefaultRowHeightInPoints();

Source Link

Document

Get the default row height for the sheet (if the rows do not define their own height) in points.

Usage

From source file:org.cgiar.ccafs.ap.summaries.projects.xlsx.BaseXLS.java

License:Open Source License

/**
 * This method writes any value into a specific cell.
 * /*from  ww  w . j  av  a 2 s. com*/
 * @param sheet is the sheet where you want to add information into.
 * @param value is the specific information to be written.
 */
public void prepareCell(Sheet sheet) {

    Row row = sheet.getRow(rowCounter);
    // if there is no row index, it should create it
    if (row == null) {
        row = sheet.createRow(rowCounter);
    }
    row.setHeightInPoints((5 * sheet.getDefaultRowHeightInPoints()));
    cell = row.createCell(columnCounter);
    cell.setCellStyle(columnStyles[columnCounter - 1]);
}

From source file:packtest.NewLinesInCells.java

License:Apache License

public static void main(String[] args) throws Exception {
    Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
    Sheet sheet = wb.createSheet();

    Row row = sheet.createRow(2);/*from  ww w.j  a v  a2 s. c o  m*/
    Cell cell = row.createCell(2);
    cell.setCellValue("Use \n with word wrap on to create a new line");

    //to enable newlines you need set a cell styles with wrap=true
    CellStyle cs = wb.createCellStyle();
    cs.setWrapText(true);
    cell.setCellStyle(cs);

    //increase row height to accomodate two lines of text
    row.setHeightInPoints((2 * sheet.getDefaultRowHeightInPoints()));

    //adjust column width to fit the content
    sheet.autoSizeColumn(2);

    FileOutputStream fileOut = new FileOutputStream("ooxml-newlines.xlsx");
    wb.write(fileOut);
    fileOut.close();
}