Hi,
I think when you set Automatic size for the text frame of a textbox, you cannot get the size of the text box, it is same as MS Excel.
Thank you.
Hi,
I think when you set Automatic size for the text frame of a textbox, you cannot get the size of the text box, it is same as MS Excel.
Thank you.
Hi,
If you set AutoSize = True , we do not re-size the text box when you change the text. We only force MS Excel auto size the text box. We will look into this feature.
OK, Thank you.
Hi,
Just wondering if the AutoSize property has been fixed to AutoSize the text box.
If not, is there now any way to get the size of the TextBox once AutoSize has been set to true.
Thanks,
Mike
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
AutoSize issue has been fixed in the latest version: Aspose.Cells
for .NET v7.4.3.2 Please download and try it. It should work fine. If you encounter any issue, please feel free to let us know.
Hi,
I tried out the 7.4.3.2 DLL and still have the same problem.
I have attached some test code, and the resultant spreadsheet.
You will notice that the TextBox Height is still the Height it was created with,
and after setting the AutoSize property on the TextFrame of the Shape seems to have no impact.
As a result, it appears that it is not possible to get the correct (Auto Sized) Height of the
TextBox, which I need to be able to do, and also have the TextBox correctly displayed when opened in MS Excel.
Could you please let me know if this is still a problem or if there is an issue with my code (attached).
Thanks.
Hi,
Thanks for your sample code and using Aspose.Cells.
We were able to replicate this issue using your sample code. We have logged this issue in our database. We will look into it and resolve this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.
This issue has been logged as CELLSNET-41685.
Hi Shakeel,
Just wondering if there has been any progress on this issue.
Thanks,
Mike
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
We are afraid, your issue is still unresolved. We have added your comment in our database. Once, there is some update for you, we will let you know asap.
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
Please try the following code with the new fix: Aspose.Cells
for .NET v7.4.3.4
C#
Hi Shakeel,
I have tried out version 7.4.3.4 and it does not seem to fix the issue.
The problem is that the shape’s height does not get resized to the correct size.
As (in the test code see attached) when TestShape.IsTextWrapped is set to true, then the height of the Shape needs to be adjusted (not the width).
I am guessing that there may be an issue with CalculateTextSize - as it always seems to always return the size of the Text as if it is being fitted to one row (which won’t necessarily be the case when wrapping the Text within the Shape)…i.e., regardless of the IsTextWrapped setting.
I have attached two spreadsheets.
The first is what happens when using version 7.4.3.4 and the test code - with AutoSize set to true and IsTextWrapped set to true.
The second spreadsheet is the same sheet, but manually edited (in MS Excel) to show the result one would expect. In this sheet, you will notice the TextBox is sized (across) the column width, but with the height adjusted to what it needs to be when using AutoSize and IsTextWrapped.
I hope this helps further explain the problem. Please get back to me if you require more details.
Look forward to getting this issue sorted out and hearing back from you on it.
Many Thanks
Mike
Hi,
Thanks for your posting and using Aspose.Cells.
You require autosize height wise while aspose is doing autosize width wise. We have noticed your requirements and logged it in our database. We will look into it and once there is some update for you, we will let you know asap.
Hi Shakeel,
I'm just wondering if there has been any more progress on this issue.
I am having trouble not being able to get the same effect as in MS Excel because the shape height is incorrect.
Many Thanks,
Mike
Hi,
Thanks for your posting and using Aspose.Cells.
We are afraid, there is no update for you at this moment. However, we have logged your comment against this issue. Please spare us some time. Once, we will have some update for you, we will let you know asap.
The issues you have found earlier (filed as CELLSNET-41685) have been fixed in this update.
I have tested this fix out with version 7.5.2 and whilst the shape is now having its height set, it appears the calculation of the height (via CalculateTextSize() method) is incorrect.
To reproduce this please use the following code. When the worksheet is opened, you will notice the height of the shape is a bit too big. If you click on the shape in Excel you will see this. If you then go Format Shape/Text Box, and then click twice on "Resize shape to fit text", you will notice Excel re-sizes the Shape correctly, which are the dimensions that I would expect the Aspose CalculateTextSize() method would return. Could you see if there is a bug in the CalculateTextSize() method, or let me know if there is something wrong with the code below.
Thanks,
Mike
private void TextBoxShapeAutoHeightIssue()
{
Workbook testWorkbook = new Workbook();
Worksheet testWorksheet = testWorkbook.Worksheets[0];
Cells testCells = testWorksheet.Cells;
int iWidth = testCells.GetColumnWidthPixel(1);
iWidth += testCells.GetColumnWidthPixel(2);
Shape testShape = testWorksheet.Shapes.AddTextBox(1, 0, 1, 0, 0, iWidth);
testCells.SetColumnWidthPixel(5, 300);
testCells[15, 5].Value = "Text Box Height - After Creation";
testCells[15, 6].Value = testShape.Height;
MsoTextFrame testTextFrame = testShape.TextFrame;
testTextFrame.BottomMarginPt = 0;
testTextFrame.LeftMarginPt = 0;
testTextFrame.RightMarginPt = 0;
testTextFrame.TopMarginPt = 0;
// SET AUTO SIZE
testTextFrame.AutoSize = true;
testTextFrame.IsAutoMargin = false;
testShape.Text = "The TextBox in the created spreadsheet does not set the height of the TextBox correctly when the TextFrame.AutoSize property is set to true.";
testShape.Placement = PlacementType.Move;
testShape.IsLocked = false;
testShape.IsPrintable = true;
testShape.IsLocked = false;
testShape.IsLockAspectRatio = true;
testShape.IsTextWrapped = true;
testShape.LineFormat.IsVisible = false;
testShape.TextOrientationType = TextOrientationType.NoRotation;
testShape.TextHorizontalAlignment = TextAlignmentType.Left;
testShape.TextVerticalAlignment = TextAlignmentType.Top;
int[] size = testShape.CalculateTextSize();
// SET THE Height and Width as returned by .CalculateTextSize()
testShape.Height = size[1];
testShape.Width = size[0];
testCells[17, 5].Value = "Text Box Height - After Setting Properties";
testCells[17, 6].Value = testShape.Height;
testWorkbook.Save(@"C:\TextBoxHeightIssue.Xlsb", SaveFormat.Xlsb);
Process.Start(@"C:\TextBoxHeightIssue.Xlsb");
}
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
We were able to observe this issue. The height of the textbox shape is bit too large and gets adjusted correctly if Resize shape to fit text is clicked twice. Please see the following screenshot for a reference.
We have logged this issue in our database. We will look into it and resolve this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.
This issue has been logged as CELLSNET-41984.
Screenshot:
Hi Shakeel,
Just wondering how you are getting on with this issue and if there is any update.
Regards,
Mike