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

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

Introduction

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

Prototype

void autoSizeColumn(int column, boolean useMergedCells);

Source Link

Document

Adjusts the column width to fit the contents.

Usage

From source file:guru.qas.martini.report.DefaultTraceabilityMatrix.java

License:Apache License

protected void resizeColumns(Sheet sheet) {
    for (int i = 0; i < columns.size(); i++) {
        sheet.autoSizeColumn(i, false);
    }//from ww  w  .  j a  va2  s . c  o m
}

From source file:org.pivot4j.ui.poi.ExcelExporter.java

License:Common Public License

/**
 * @param context//from w w  w .  j  av a 2 s.c  om
 * @param sheet
 */
protected void adjustColumnSizes(TableRenderContext context, Sheet sheet) {
    for (int i = 0; i < context.getColumnCount(); i++) {
        try {
            sheet.autoSizeColumn(getColOffset() + i, !mergedRegions.isEmpty());
        } catch (Exception e) {
            // Ignore any problem while calculating size of the columns.
        }
    }
}