Possible bug concerning Font Size and Row Height

Hello. I have an issue concerning the height of a row before and after I increase the font size of a cell with content in the row. In my code below I do this:

  1. I enter some text into cell “A1”.
  2. Output the height of row “1:1”. Displays 12.75
  3. Increase the font size of cell “A1”.
  4. Output the height of row “1:1” again. Displays 12.75 but I expect it to display 25.5.
The problem here is that after increasing the font size, the row height should also increase. This is what happens if I do this directly in Excel. If I open the generated file after running this code, the row height is clearly larger than any other row (See attached image)

Is this a bug in the Aspose.Cells code? What is the work-around for this? Here’s my code that replicates this:

static void Main(string[] args)
{
const string filename = @“pathToFile”;

var workbook = new Workbook();
var cells = workbook.Worksheets[0].Cells;
var row = cells.Rows[0];
var cell = cells[0, 0];
cell.Value = “Hello World”;

Console.WriteLine(row.Height); //12.75

var style = cell.GetStyle();
style.Font.Size = 20;
cell.SetStyle(style);

Console.WriteLine(row.Height); //12.75 (should be 25.5)

workbook.Save(filename);

Console.WriteLine(“press enter”);
Console.ReadLine();
}

Hi Jordan,

Thanks for your posting and using Aspose.Cells.

You should call Worskheet.AutoFitRow(s) method for your needs. Please add the following line in your code and it will return correct row height.

workbook.Worksheets[0].AutoFitRow(row.Index);

Here is the full code for your reference. I have highlighted the changes in red color.

C#


var workbook = new Workbook();

var cells = workbook.Worksheets[0].Cells;

var row = cells.Rows[0];

var cell = cells[0, 0];

cell.Value = “Hello World”;


Console.WriteLine(row.Height); //12.75


var style = cell.GetStyle();

style.Font.Size = 20;

cell.SetStyle(style);


workbook.Worksheets[0].AutoFitRow(row.Index);


Console.WriteLine(row.Height); //12.75 (should be 25.5)


workbook.Save(“output.xlsx”);


Console.WriteLine(“press enter”);

Console.ReadLine();