Search in sources :

Example 1 with Col

use of org.xlsx4j.sml.Col in project com.revolsys.open by revolsys.

the class XlsxRecordWriter method addHeaderRow.

private void addHeaderRow(final Worksheet worksheet, final RecordDefinition recordDefinition) {
    final List<Cols> columnGroups = worksheet.getCols();
    final Cols columns = smlObjectFactory.createCols();
    columnGroups.add(columns);
    final Row headerRow = smlObjectFactory.createRow();
    this.sheetRows.add(headerRow);
    final List<Cell> cells = headerRow.getC();
    for (final FieldDefinition field : recordDefinition.getFields()) {
        final String fieldName = field.getName();
        final Col column = smlObjectFactory.createCol();
        columns.getCol().add(column);
        column.setMin(field.getIndex() + 1);
        column.setMax(field.getIndex() + 1);
        column.setBestFit(true);
        final int textLength = Math.min(40, Math.max(fieldName.length() + 2, field.getMaxStringLength()));
        column.setWidth(textLength * 1.25);
        addCellInlineString(cells, fieldName);
    }
}
Also used : Col(org.xlsx4j.sml.Col) Cols(org.xlsx4j.sml.Cols) FieldDefinition(com.revolsys.record.schema.FieldDefinition) Row(org.xlsx4j.sml.Row) Cell(org.xlsx4j.sml.Cell)

Aggregations

FieldDefinition (com.revolsys.record.schema.FieldDefinition)1 Cell (org.xlsx4j.sml.Cell)1 Col (org.xlsx4j.sml.Col)1 Cols (org.xlsx4j.sml.Cols)1 Row (org.xlsx4j.sml.Row)1