cells[1,1].GetHeightOfValue get a wrong result,if use chinese

I want to insert a page break in the right place by calculating the row height,but this problem makes the position calculation wrong.
image.jpg (70.6 KB)

public void CreateDemo(string demopath)
{
Workbook workbook = new Workbook();
workbook.Worksheets.Clear();

Style style3 = workbook.CreateStyle();
style3.Font.Size = 12;
style3.IsTextWrapped = true;

var sheet = workbook.Worksheets.Add("test");
sheet.Cells.SetColumnWidthPixel(1, 200); //setwidth

//Spaces in different positions will get different result,40,60
//but if open the excel,they are the same
string str1 = "测试数据的换行问题12121212121212 测试数据换行";
string str2 = "测试数据的换行问题 12121212121212测试数据换行";

Cells cells = sheet.Cells;
cells[1, 1].PutValue(str1);
cells[1, 1].SetStyle(style3);
var h1 = cells[1, 1].GetHeightOfValue();//result is 40

cells[2, 1].PutValue(str2);
cells[2, 1].SetStyle(style3);
var h2 = cells[2, 1].GetHeightOfValue();//result is 60

workbook.Save(demopath, SaveFormat.Xlsx);

}

Blockquote
can you help me? thank you.

@epepep,
We have logged the issue as “CELLSNET-47861” in our database for investigations. Once we will have some news for you, we will update you in this topic.

@epepep,
Please set Chinese font for Chinese character, then call worksheet.AutoFitRows() method to fit row height, see following codes:

Workbook workbook = new Workbook();            
workbook.Worksheets.Clear();
Style style3 = workbook.CreateStyle();            
style3.Font.Name = "宋体";            
style3.Font.Size = 12;            
style3.IsTextWrapped = true;
var sheet = workbook.Worksheets.Add("test");            
sheet.Cells.SetColumnWidthPixel(1, 200); //setwidth
//Spaces in different positions will get different result,40,60            
//but if open the excel,they are the same            
string str1 = "测试数据的换行问题12121212121212 测试数据换行";            
string str2 = "测试数据的换行问题 12121212121212测试数据换行";
Cells cells = sheet.Cells;            
cells[1, 1].PutValue(str1);            
cells[1, 1].SetStyle(style3);            
var h1 = cells[1, 1].GetHeightOfValue();
cells[2, 1].PutValue(str2);
cells[2, 1].SetStyle(style3);            
var h2 = cells[2, 1].GetHeightOfValue();            
sheet.AutoFitRows();            
Console.WriteLine(cells.GetRowHeightPixel(1));
workbook.Save(dir +"dest.xlsx", SaveFormat.Xlsx);

Let us know your feedback.

@ahsaniqbalsidiqui
it dons’t work, after set Chinese font , the height is change, But the heights of the two lines are still different.
image.png (4.5 KB)
excelview.png (1.5 KB)
In fact, the calculation height of the second line(str2) is accurate.There is something wrong with the height calculation of the first line(str1).
There is no space between Chinese and numbers(str1,测试数据的换行问题121), excel will also wrap lines, but the calculation seems not to consider.

@epepep,
Thanks for the feedback. We will share our feedback soon.

@epepep,

This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

ok,thank you

@epepep
Please try the latest fix 21.2.4.
Aspose.Cells21.2.4 For .Net2_AuthenticodeSigned.Zip (5.5 MB)
Aspose.Cells21.2.4 For .Net4.0.Zip (5.5 MB)
Aspose.Cells21.2.4 For .NetStandard20.Zip (5.5 MB)

The issues you have found earlier (filed as CELLSNET-47861) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao