Moreover, I did evaluate the issue using our latest version (we cannot evaluate or test issues using older versions, neither we can include fixes against issues (if found) to older versions. The fixes are based on latest APIs only) and found it also does not work good in latest APIs, we need to evaluate it further though:
e.g Sample code:
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
//Adding a sample value to "A1" cell
Cell w_cell = worksheet.getCells().get("A1");
Style w_cellStyle = w_cell.getStyle();
w_cell.setValue("Khushbu Ruchita Seema Ajay Goshnat Pankaj Tarun");
w_cellStyle.setTextWrapped(true);
w_cell.setStyle(w_cellStyle);
String w_filePath = "e:\\test\\School.jpg";
int w_picIndex = worksheet.getPictures().add(0,1,w_filePath);
Picture w_pic = worksheet.getPictures().get(w_picIndex);
w_pic.setPlacement(PlacementType.FREE_FLOATING);
//w_pic.setHeight(16);
//w_pic.setWidth(16);
w_pic.setLockAspectRatio(true);
w_pic.setLocked(true);
//Saving the Excel file
workbook.save("f:\\files\\out1.xls");
As we already did evaluate the issue using our latest version and sample code and found it also does not work good in latest APIs, the image in the cell is expanded a bit when text is wrapped in the adjacent cell in the worksheet. I have logged a ticket with an id “CELLSJAVA-42877” for your issue. We will look into it soon.
Once we have an update on it, we will let you know here.
I am afraid, AutoFitterOptions have been included in recent versions, so you got to upgrade to latest version if you can. By the way, you may give it a try by using the line if it works fine:
e.g Sample code:
..........
worksheet.autoFitRows();
...........
In case the above workaround does not fix the issue, I am afraid, there is no other alternative but to upgrade to latest APIs set as we cannot include any enhancements to older versions.
I have used Row.setAutoFitHeight(false);.
This resolved my problem. Thank you very much.
I need one more help, I want to set the height of the row such that all the content in the cell will be visible at one glance.
This this used to happen previously as AutoFitHeight was not set to false. and row height was used to increased because wrappedText.
I used row.setHeight(value) to increase the height of the row with appropriate value, its useful for me.
But I need one proper formula, so that I can adjust the height of the row depending upon the cell content.
Good to know that your original issue is sorted out now.
Regarding your newer query, it looks like you want to get the height of the content. The feature was not included in older version. I am afraid if you want to avail the feature (get height/width of cell value string) you have to upgrade to latest version/fix.
Can you help me with the formula which is used internally to set the RowHeight when setWrappedText(true) is used.
I have columnWidth, value in a cell and fontsize as a input parameters. There should be some corelation between these parameters to calculate rowHeight.
Well if Row.AutoFitHeight is true, MS Excel (being an application) will automatically expand row height to show the content of the cell. Aspose.Cells just calculates row heights with the classes of java.awt package. Also, it’s very complex and we cannot evaluate on how to calculate row heights with some simple codes.