Autofitrows feature not working when editing the Excel file

Hi,

We are using the Aspose.Cells for .Net and we have a problem with the Autofitrows feature, the problem is the following one:

We create a workbook and then a worksheet, set the cells to wrap the text, then we populate that worksheet with some data and in the end we use the Autofitcolumns and Autofitrows features to adjust the columns and rows to the data.

It's works just fine, the generated Excel file is presented as we expected, the problem is that when someone edit that Excel (add some text in one of the existing cells) the rows doesn't autofit to the new content automatically, and if we do the same test in a new Excel file (created using Excel) just setting the cells to wrap the text the row heigth is automatically autofit to the cell content.

Is this a problem with Aspose.Cells??

Are we doing something wrong??

Thanks in advance for your support.

Luis Estevens

Hi,

Thanks for considering Aspose.

Well, Generally Aspose.Cells's auto-formatting rows/columns and wrapping text features work in the same way as MS Excel. Could you elaborate and give us more details, possibly give your template and output file with sample code. We will check and figure out the issue soon.

Thank you.

Hello,

I attached to this message 2 excel files, the one called original.xls is the one generated by the ASPOSE and the original_edited.xls is the same file but after being edited using the Excel.

As you can see in the original file everything is ok, the autofit worked just fine, but when we edit one cell in that file (in this case cell G6) adding more text to the cell the autofit isn't done by the Excel, and if we do the same test in a blank worsheet the Excel normal beahviour is to autofit the row when the cell content is too big (if the cell is set to wrap text).

Where is the code that we are using:

excelWorkbook = new Workbook();
excelWorksheet = excelWorkbook.Worksheets[0];

excelWorksheet.IsGridlinesVisible = false;
excelWorkbook.Styles.Add();
excelWorkbook.Styles[0].Font.Color = Color.FromArgb(0, 51, 102);
excelWorkbook.Styles[0].Font.Name = "Verdana";
excelWorkbook.Styles[0].Font.Size = 10;
excelWorkbook.Styles[0].HorizontalAlignment = TextAlignmentType.Center;
excelWorkbook.Styles[0].VerticalAlignment = TextAlignmentType.Center;
excelWorkbook.Styles[0].Borders.SetColor(Color.FromArgb(153, 204, 255));
excelWorkbook.Styles[0].Borders.DiagonalStyle = CellBorderType.None;
excelWorkbook.Styles[0].Number = 49;
excelWorkbook.Styles[0].IsTextWrapped = true;

excelWorksheet.Cells.ImportDataTable(reportData, false, numHeaderRows, 0, false);

excelWorksheet.AutoFitColumns();
excelWorksheet.AutoFitRows();

excelWorkbook.Save(filename, FileFormatType.Default, SaveType.OpenInExcel, this.Response);

Hi,

Thanks for briefing with template files,

We will figure out and get back to you soon.

Thank you.

Dear Luis,

There are some differences between Aspose.Cells AutoFitRow method and MS Excel's autofit feature. So we have to disable auto row height extend with extra content.

For example, when autofit a row, Aspose.Cells will calculate it's height as 23.25 but MS Excel will show it as 24. That doesn't matter for display however it may distort images and other drawing shapes.

So we disable MS Excel to automatically extend row height based on cell content. You have to manually adjust it in MS Excel.