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);
}
}
Aggregations