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