autoFitRows() / setWrapTex() is not working on merged cells

Hi,

In case of merged cells setTextWrapped(true) / worksheet.autoFitRows() is not working as expected.

Please have a look at following code snippet and also on attached sample excel sheet generated in 2003 and 2007 version. As per the written code, height of 4th row should have been adjusted to accommodate the text in merged cells C4 and D4.

Please provide a solution ASAP.

Row row = worksheet.getCells().getRow(3);

// merge first and second cell
worksheet.getCells().merge(3, 0, 3, 1);
// merge third and fourth cell
worksheet.getCells().merge(3, 2, 3, 3);
// merge fifth and sixth cell
worksheet.getCells().merge(3, 4, 3, 5);

Cell cell = row.getCell(0);
cell.setValue("Short Text");

cell = row.getCell(2);
cell.setValue("This is a long text and this should be wrapped");

cell = row.getCell(4);
cell.setValue("This is a medium text");

// Accessing the newly added Style to the Excel object
Style style = workbook.createStyle();
style.setTextWrapped(true);
// Creating StyleFlag
StyleFlag styleFlag = new StyleFlag();
styleFlag.setWrapText(true);
// Assigning the Style object to the Style property of the row
row.applyStyle(style, styleFlag);
worksheet.autoFitRows();

Thanks.
Vineet.

Hi Vineet,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Well, rows will not get affected by AutoFitRow when there are merged cells in them. You may check it manually in MS Excel too. I think you may try setting row height if it fits your need. Please see the following documentation link in this regard:

http://www.aspose.com/documentation/java-components/aspose.cells-for-java/adjusting-row-height-column-width.html

Thank You & Best Regards,