Aspose.Cells.Drawing.TextBox AutoSize issue

Hello Support Team,

Since Aspose.Cells v22.10.0, textbox’s CalculateTextSize() returns incorrect height.

This is how I added a textbox to a worksheet.

        int textboxIndex = sheet.TextBoxes.Add(1, 1, 60, 200);
        TextBox textbox0 = sheet.TextBoxes[textboxIndex];
        textbox0.IsTextWrapped = true;
        textbox0.TextBody.TextAlignment.RightMarginPt
            = textbox0.TextBody.TextAlignment.LeftMarginPt
            = textbox0.TextBody.TextAlignment.TopMarginPt
            = textbox0.TextBody.TextAlignment.BottomMarginPt
            = 2;
        textbox0.TextBody.TextAlignment.AutoSize = true;
        textbox0.TextBody.TextAlignment.TextVerticalOverflow = TextOverflowType.Clip;
        textbox0.Font.Size = 14;
        textbox0.Text = "The UK economy shrank by more than expected in October, as higher interest rates squeezed consumers and bad weather swept the country.The economy fell 0.3% during the month, after growth of 0.2% in September.";
        var sizes = textbox0.CalculateTextSize();
        textbox0.Width = sizes[0];
        textbox0.Height= sizes[1];

I have confirmed that this works correctly up to Aspose.Cells v22.9.0.

@AT1,

Thanks for the details.

I am able to reproduce the issue as you mentioned by using your sample code segment. I found auto-size issue with Aspose.Cells.Drawing.TextBox. Since Aspose.Cells v22.10.0, textbox’s CalculateTextSize() returns incorrect height.

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
int textboxIndex = sheet.TextBoxes.Add(1, 1, 60, 200);
TextBox textbox0 = sheet.TextBoxes[textboxIndex];
textbox0.IsTextWrapped = true;
textbox0.TextBody.TextAlignment.RightMarginPt = textbox0.TextBody.TextAlignment.LeftMarginPt = textbox0.TextBody.TextAlignment.TopMarginPt = textbox0.TextBody.TextAlignment.BottomMarginPt = 2;
textbox0.TextBody.TextAlignment.AutoSize = true;
textbox0.TextBody.TextAlignment.TextVerticalOverflow = TextOverflowType.Clip;
textbox0.Font.Size = 14;
textbox0.Text = "The UK economy shrank by more than expected in October, as higher interest rates squeezed consumers and bad weather swept the country.The economy fell 0.3% during the month, after growth of 0.2% in September.";
var sizes = textbox0.CalculateTextSize();
textbox0.Width = sizes[0];
textbox0.Height= sizes[1];
Console.WriteLine(textbox0.Width);//200 - Ok
Console.WriteLine(textbox0.Height);//30 - Not Ok ... v22.9 gives 235.

We required thorough evaluation of your issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-54780

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@amjad.sahi

Thank you very much for your quick response.

As we haven’t got any plans to upgrade Aspose.Cell version so far, will be waiting for fixes.

Many thanks for your support.

@AT1,

Sure, we will be looking into your issue and try to figure it out soon.

Once we have an update on it, we will let you know.

@AT1
Hello,
Your issue (CELLSNET-54780) has been resolved and the fixed functionality will be released with version 24.1.
Since the version starting from 22.10 is based on SkiaSharp, there are some small deviations in the underlying processing. Therefore, there will be differences between previous and later versions of the same code. After the problem is fixed, textbox0.Height=237.
Or you can use the system.drawing.common based version (as of 22.10.1) and the results will be the same as before. Please see How to Run Aspose.Cells for .Net6|Documentation for instructions on use.

@duojie.yang

Thank you very much for the clarification and the fix.
I also confirmed that the System.Drawing.Common based version worked as expected.

I am so grateful for your support. Thanks again.

@AT1
Thank you for your feedback. I’m glad your issue has been resolved. If you have any questions, please feel free to contact us.

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

This problem still occurs when texts is in Japanese. Can you please take a look at it?

        textbox0.Text = "(ブルームバーグ): バイデン米大統領が事実上の禁輸リスト「エンティティーリスト」に追加した中国企業・個人の数が、歴代の米政権で最多となった。米中間の摩擦の高まりが、引き続き世界の貿易を複雑化させている。米商務省は11日、中国企業6社をエンティティーリストに追加。バイデン政権下で新たに禁輸対象となった中国企業・個人の数は319に達した。これはトランプ前政権中に追加された306を上回る。当時は米中貿易戦争が両国の経済に打撃を与えていた。";

@AT1,
Is it same issue as we reproduced in your other thread? If not, kindly provide complete sample code and sample files to demonstrate the issue, we will check it soon.

This is a separated issue. The sample code is in my original post of this thread. The fix for CELLSNET-54780 works with English text but not with Japanese text.

@AT1,

We have logged it with your existing ticket “CELLSNET-55518” for your issue. We will look into it soon.

@AT1
Hello,
Your issue (CELLSNET-55518) has been resolved and the fixed functionality will be released with version 24.5.