Hi,
We have found issue with autoFitRows method. It does not work if we call twice:
public void testAutoFitRows() throws Exception {
Workbook wb = new Workbook();
Worksheet worksheet = wb.getWorksheets().get(0);
Cells cells = worksheet.getCells();
Row row = cells.getRows().get(0);
System.out.println("Initial size: " + row.getHeight());
// Set the width of first column
cells.setColumnWidth(0, 10);
// Set wrap text option
Style style = cells.get(0, 0).getStyle();
style.setTextWrapped(true);
cells.get(0, 0).setStyle(style);
System.out.println("After change cell format: " + row.getHeight());
// Apply auto-fit without data
AutoFitterOptions options = new AutoFitterOptions();
options.setOnlyAuto(true);
options.setAutoFitMergedCells(true);
options.setIgnoreHidden(true);
worksheet.autoFitRows(options);
System.out.println("After first call autoFitRows without data on sheet: " + row.getHeight());
cells.get(0, 0).putValue(“This is a autoFitRows second call issue”);
// Second call auto-fit
worksheet.autoFitRows(options);
System.out.println("After second call autoFitRows with data on sheet: " + row.getHeight());
}
Output looks as follows:
Initial size: 12.75After change cell format: 12.75After first call autoFitRows without data on sheet: 12.75After second call autoFitRows with data on sheet: 12.75
Correct result looks as follows:
After second call autoFitRows with data on sheet: 51.0
Could you review and fix this issue?
Thanks.