Cells Comment Size Autosizing while keeping either height or width constant

Is it possible to Autosize a comment on a cell while keeping either the width or the height constant?

For example, if I have variable comment lengths and I don’t want to explicitly define the comment box size every time I add a comment, is it possible to keep the width as 5 cm, but autosize the height such that the entire comment is shown?

Thanks

@jasonleecanalyst,

Thanks for your query.

I tested your scenario/ case using MS Excel and Aspose.Cells APIs but could not accomplish the exact task 100% as per your needs. I ended up with the following approaches which might not perform your exact task but you may give it a try to any of the following methods to best suit your needs:

 Workbook workbook = new Workbook();

            Worksheet worksheet = workbook.Worksheets[0];
            
            var comment = worksheet.Comments[worksheet.Comments.Add("A1")];
            comment.Note = "This is some sample text that would appear within the cell comment. This is the ending line of the comment. This is other line. This is test. This is test.";
            comment.CommentShape.WidthCM = 5;
            comment.CommentShape.HeightCM = 3;//you have to provide height as well based on your data accordingly by yourself.
            comment.CommentShape.IsTextWrapped = true;
            comment.CommentShape.Placement = PlacementType.Move;
            
            workbook.Save("e:\\test2\\outcommentshape1.xlsx");  
//Another way to use escape sequence "\n" that you may try, you may insert line breaks for your desired positions of the text.
            Workbook workbook = new Workbook();

            Worksheet worksheet = workbook.Worksheets[0];
            
            var comment = worksheet.Comments[worksheet.Comments.Add("A1")];
            comment.Note = "This is some sample text that would appear\n within the cell comment. This is\n the ending line of the comment. This is\n other line. This is test. This is\n test.";
            
            comment.CommentShape.IsTextWrapped = true;
            comment.CommentShape.Placement = PlacementType.Move;
            comment.AutoSize = true;

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

By the way, if you could accomplish your exact task in MS Excel manually, kindly do provide complete details and steps involved with sample file(s), we will check it on how to do it via Aspose.Cells APIs.