We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Autofitting merged cells

Hi,


I’m currently having some issues concerning autofitting merged cells.
as example:
I have merged cell A1 with A2 and it contains a large text. style.textwrapped = true.
Column A3 contains a small text.
Autofitrows (with autofitter.AutofitMergedCells =true) and autofitcolumns are called.
When the excel is generated, the rowheight of row A has stretched a little but not enough,
there is still some text that is not displayed in the cell

code:
var workbook = new Workbook();
var workSheet = workbook.Worksheets[0];
workSheet.Cells[2, 0].PutValue(123);
workSheet.Cells[0, 0].PutValue(“qsfjklhqsklmddjrdlrvjnlqsejrlc jalrvjqselvrjqjslr jmqlsdjlmqjsdgfqsdjfjqlmsj end”);
var style = workSheet.Cells[0, 0].GetStyle();
style.IsTextWrapped = true;
workSheet.Cells[0, 0].SetStyle(style);
workSheet.Cells.Merge(0, 0, 1, 2);
workSheet.AutoFitRows(new AutoFitterOptions { AutoFitMergedCells = true });
workSheet.AutoFitColumns();
workbook.Save(filename);

any suggestions of what i am doing wrong?

Grtz
Hi,


I have tested your issue with our latest version/fix: Aspose.Cells for .NET v7.4.2.3 (please try it), it works fine. The text in the A1 cell can be seen fully which is autofitted.

Sample code:

var workbook = new Workbook();
var workSheet = workbook.Worksheets[0];
workSheet.Cells[2, 0].PutValue(123);
workSheet.Cells[0, 0].PutValue("qsfjklhqsklmddjrdlrvjnlqsejrlc jalrvjqselvrjqjslr jmqlsdjlmqjsdgfqsdjfjqlmsj end");
var style = workSheet.Cells[0, 0].GetStyle();
style.IsTextWrapped = true;
workSheet.Cells[0, 0].SetStyle(style);
workSheet.Cells.Merge(0, 0, 1, 2);
workSheet.AutoFitRows(new AutoFitterOptions { AutoFitMergedCells = true });
workSheet.AutoFitColumns();
workbook.Save("e:\\test2\\output__mergedcells.xlsx");

Thank you.