Aspose.Cells.Drawing.TextBox AutoSize issue

@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.

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

Hi, this issue still occurs when text has a line break.
Please use the code in my first post and change the text as below.

textbox0.Text = “先進7か国首脳会議(G7サミット)でイタリアを訪問中の米国のバイデン大統領(81)が13日、G7首脳の夕食会を欠席した。イタリアメディアは関係者の話として、疲労のためだと伝えた。11月の大統領選が迫る中、高齢と体力の衰えを不安視する声が強まっている。\n夕食会は、サミット会場に近い中世の城で行われ、バイデン氏以外の首脳は出席した。米ホワイトハウスは、欠席理由は日程上の都合だと説明している。”;

@AT1
We reproduced your issue,

Console.WriteLine(textbox0.Height);//101 - Not Ok ... 511 - OK.

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-55979

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.

@AT1,

I tested your scenario/case with your text/string using the following sample code. It seems the text box size is OK and output XLSX file (attached) is also OK. I am using Aspose.Cells for .NET v24.6 (please try it).
e.g.,
Sample code:

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 = "US President Biden (81), who is visiting Italy for the G7 Summit, missed the G7 leaders' dinner on the 13th. Italian media reported that he was absent due to fatigue, citing a source close to the matter. With the presidential election in November approaching, concerns are growing over his age and declining physical strength.\nThe dinner was held at a medieval castle near the summit venue, and all leaders except Biden attended. The White House explained that the reason for his absence was due to a scheduling conflict.";
var sizes = textbox0.CalculateTextSize();
textbox0.Width = sizes[0];
textbox0.Height= sizes[1];
Console.WriteLine(textbox0.Width);//200
Console.WriteLine(textbox0.Height);//561

workbook.Save("e:\\test2\\out1.xlsx");

Please find attached the output XLSX file for your reference.
out1.zip (7.2 KB)

@amjad.sahi

Because you have translated the Japanese text into English. It only happens in Japanese.

@AT1,

Alright, thank you for providing further details. We have already reproduced the issue and @xinya.zhu has logged a new ticket (“CELLSNET-55979”) for it. We will look into your issue and get back to you with new updates once they are available.

@AT1
Hi,
Your issue (CELLSNET- 55979) has been resolved and the fixed functionality will be released with version 24.7.

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