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

Free Support Forum - aspose.com

Unable to fit row height to its content when using HtmlString

Hello,

I am putting an HTML content into a cell in order to control formatting of individual text parts:

var workbook = new Workbook();
var sheet = workbook.Worksheets[0];
var cell = sheet.Cells[0, 0];

cell.HtmlString = @"<Font Style=""FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #808080;"">Updated </Font><Font Style=""FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #000000;"">translation</Font><br/><Font Style=""FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #ff7f50;"">Reviewer </Font><Font Style=""FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #000000;"">translation</Font>";

var cellStyle = cell.GetStyle();

var row = sheet.Cells.Rows[0];
var style = row.Style;
style.IsTextWrapped = true;
row.ApplyStyle(style, new StyleFlag { WrapText = true });

sheet.AutoFitRows();
sheet.AutoFitColumns();

workbook.Save(@"f:\test\cells-format.xlsx", SaveFormat.Xlsx);

However, the cell does not display correctly. In particular, its height does not fit the content:

https://www.dropbox.com/s/m6wu86nkkwl94qj/aspose_cells.PNG?dl=0

Is there anything I can do about it?

Thank you.

@standa.kurik

Thanks for using Aspose APIs.

Please download and try the most recent version. It works fine. I have attached the output Excel file as well as screenshot showing the output for your reference.

Download Link:
Output Excel File.zip (5.8 KB)
Aspose.Cells for .NET 17.10.3

Screenshot:

Thank you Shakeel. I was indeed using the latest version, but opening the resulting file in LibreOffice, which, unlike Excel, renders the content incorrectly. Consider this settled then, thanks!

Best regards,
Standa

@standa.kurik

Thanks for your feedback and using the Aspose APIs.

It is good to know that you found the root cause of this issue. Let us know if you encounter any other issue, we will like to help you more.