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