-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Labels
Description
Description
When using spreadsheet.autoFitColumn(index); the automatic adjustment leaves the column width ever so slightly too small for the contents to actually fit. This used to work just fine with the old Vaadin Framework Spreadsheet, both versions 2.1.1 and 3.0.0, so a regression has crept in at some point.
With the latest Flow Spreadsheet the end result looks like this:
Expected outcome
After calling spreadsheet.autoFitColumn(index); I would expect the end result to look like this:
Minimal reproducible example
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("Employees");
Row header = sheet.createRow(0);
header.createCell(0).setCellValue("ID");
header.createCell(1).setCellValue("Name");
header.createCell(2).setCellValue("Age");
header.createCell(3).setCellValue("Email");
header.createCell(4).setCellValue("Salary");
for (int i = 1; i <= 8; i++) {
Row row = sheet.createRow(i);
row.createCell(0).setCellValue(i);
row.createCell(1).setCellValue("User " + i);
row.createCell(2).setCellValue(20 + i);
row.createCell(3).setCellValue("user" + i + "@example.com");
row.createCell(4).setCellValue(42000 + i * 1500);
}
Spreadsheet spreadsheet = new Spreadsheet(workbook);
spreadsheet.setSizeFull();
add(spreadsheet);
spreadsheet.setMaxRows(9);
spreadsheet.setMaxColumns(5);
for (int i = 0; i <= 4; i++) {
spreadsheet.autofitColumn(i);
}
spreadsheet.refreshAllCellValues();Or you can just go to one of the documentation examples, and double click the column width adjustment line to see the behaviour.
Steps to reproduce
- add the snippet above into a view
- look at the column widths, especially the last two
Environment
Vaadin version(s): 24.9.4, also broken with 24.9.2 and 24.9.3.
OS: macOS
Browsers
Firefox, Chrome, Safari
AndriiRevaEpicor and NatalyaBranets-fpa