We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problems with autosize

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#


Workbook TestWorkbook = new Workbook();

Worksheet TestWorksheet = TestWorkbook.Worksheets[0];

Cells TestCells = TestWorksheet.Cells;

Shape TestShape = TestWorksheet.Shapes.AddTextBox(1, 0, 1, 0, 50, TestCells.GetColumnWidthPixel(1));


TestCells.SetColumnWidthPixel(5, 300);

TestCells[1, 5].Value = “Text Box Height - After Creation”;

TestCells[1, 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 size the TextBox when the TextFrame.AutoSize property is set to true.”;

TestShape.Placement = PlacementType.Move;

TestShape.IsLocked = false;

TestShape.IsPrintable = true;

TestShape.IsLocked = false;

TestShape.IsLockAspectRatio = false;

TestShape.IsTextWrapped = true;

TestShape.LineFormat.IsVisible = false;

TestShape.TextOrientationType = TextOrientationType.NoRotation;

TestShape.TextHorizontalAlignment = TextAlignmentType.Left;

TestShape.TextVerticalAlignment = TextAlignmentType.Top;

int[] size = TestShape.CalculateTextSize();

TestShape.Width = size[0];

TestShape.Height = size[1];


TestCells[2, 5].Value = “Text Box Height - After Setting Properties”;

TestCells[2, 6].Value = TestShape.Height;

Hi Shakeel,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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.

Hi,

We have fixed the issue.


Please download and try this fix: Aspose.Cells for .NET v7.5.0.4 and let us know your feedback.

Thank you.

The issues you have found earlier (filed as CELLSNET-41685) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

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

Hi Mike,


Please download and try our latest version/fix: Aspose.Cells for .NET v7.5.3.4 your issue should be fixed in it.

Let us know your feedback.

Thank you.

Many thanks again Amjad,

I have just smoked tested this one also and looks great. Thank you very much. I'll do a few more tests in the coming days.

Many thanks to you and your team.

Best regards,

Mike

Hi Mike,


Thanks for your feedback.

Good to know that your issue is resolved by the new fix/version: Aspose.Cells for .NET v7.5.3.4. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.

The issues you have found earlier (filed as CELLSNET-41984) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Amjad,

I have done some more testing on this issue and unfortunately it appears it is still problematic and has bugs.

Please see the attached code that demonstrates that the height is not always being set to the correct value, depending on fonts, formatting, justification etc.

Also it has shown up problems that the text boxes as they appear in Excel do not get rendered to either xps or pdf correctly (i.e., they can appear different in xps and pdf than Excel). This also can be seen in the attached code output.

This is a major issue for software I am about to release, so your earliest attention and resolution to these issues would be greatly appreciated.

Many Thanks,

Mike

Hi Mike,

Thanks for your posting and using Aspose.Cells for .NET.

We were able to observe this issue. CalculateTextSize does not return correct height of the textbox. We have attached the output files generated by your code to illustrate this issue. We have logged this issue in our database for investigation. 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-42104.

Hi Shakeel,

Just wondering how progress is going sorting this problem out.

This is a big issue for us, and any feedback you could give me as to a date of a likely resolution and a fix would be very much appreciated.

Look forward to hearing from you.

Cheers

Mike

Hi Mike,

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 in our database against this issue and requested the development team to provide some update or fix for this issue. Please spare us some time. Once, we will have some fix or update for you, we will let you know asap.

Have just downloaded and installed Aspose Cells 7.7.0.

I don’t think this has been fixed.

Could you please let me know when you expect a fix to be available.

Thanks,

Mike

Hi Mike,

Thanks for your posting and using Aspose.Cells.

Your issue logged as CELLSNET-42104 is not yet resolved. However, we have added your comment in our database and requested the development team to provide some ETA or update for this issue. Once, there is some news for you, we will let you know asap.