Hi,
We have found another issue with autoFitRows method. It does not take into consideration data in hidden columns:
public void autoHeight() 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 for cells
Style style = cells.get(0, 0).getStyle();
style.setTextWrapped(true);
cells.get(0, 0).setStyle(style);
cells.get(0, 1).setStyle(style);
cells.get(0, 2).setStyle(style);
// Merge cells
cells.merge(0, 1, 1, 2);
System.out.println("After change cell format: " + row.getHeight());
cells.get(0, 0).putValue(“This is a autoFitRows call test”);
cells.get(0, 1).putValue(“This is a merged cells to test auto-fit in scope of hidden column”);
cells.hideColumn(0);
// Apply auto-fit
AutoFitterOptions options = new AutoFitterOptions();
options.setOnlyAuto(true);
options.setAutoFitMergedCells(false);
options.setIgnoreHidden(false);
worksheet.autoFitRows(options);
System.out.println("After call autoFitRows with data on sheet: " + row.getHeight());
wb.save(“d:\test.xlsx”);
}
Output looks as follows:
Initial size: 12.75
After change cell format: 12.75
After call autoFitRows with data on sheet: 12.75
If you open output file in MS Excel, it automatically fits first row even first column is hidden (height of the first row 38.25 instead of 12.75).
Could you fix this issue (or add an option to AutoFitterOptions to take into consideration data in hidden columns)?
Thanks.