RoundedRectangle with multiple line of text then font size not apply on onyl first line

comment shape1.zip (14.1 KB)

@tejas.patel,

Thanks for the sample file with code snippet to demonstrate the issue.

Please see to the following sample code on how to add rounded rectangles with multiple lines of text whose text will be rendered with same font size, color and styles for every line for your reference. Please refer to it and write/update your own code accordingly for your requirements.
e.g
Sample code:

var workbook = new Workbook();
var sheet = workbook.Worksheets[0];

// Add two rounded rectangles with multi-line text
AddMultiLineRoundedShape(sheet, row: 1, col: 1, widthPx: 200, heightPx: 280, text: "Line one of text\nSecond line here\nThird line", fontSize: 9,
fillColor: System.Drawing.Color.LightYellow, borderColor: System.Drawing.Color.Blue, fontColor: System.Drawing.Color.DarkRed);

AddMultiLineRoundedShape(sheet, row: 10, col: 1, widthPx: 250, heightPx: 180, text: "Another shape\nWith multiple\nLines!", fontSize: 8,
fillColor: System.Drawing.Color.LightCyan, borderColor: System.Drawing.Color.Green, fontColor: System.Drawing.Color.Black);

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

static void AddMultiLineRoundedShape(Worksheet sheet, int row, int col, int widthPx, int heightPx, string text, int fontSize, System.Drawing.Color fillColor, System.Drawing.Color borderColor, System.Drawing.Color fontColor)
{
                var shape = sheet.Shapes.AddAutoShape(
                AutoShapeType.RoundedRectangle,
                row, 0, col, 0, widthPx, heightPx);

            shape.Text = text;
            shape.IsTextWrapped = true;
            shape.TextHorizontalOverflow = TextOverflowType.Clip;
            shape.TextVerticalOverflow = TextOverflowType.Clip;
            shape.TextHorizontalAlignment = TextAlignmentType.Center;
            shape.TextVerticalAlignment = TextAlignmentType.Center;

            foreach (TextParagraph para in shape.TextBody.TextParagraphs) 
            {
                // Apply uniform font size and color
                para.Font.Name = "Arial";
                para.Font.Size = fontSize;
                para.Font.Color = fontColor;
            }

            shape.Fill.FillType = Aspose.Cells.Drawing.FillType.Solid;
            shape.Fill.SolidFill.Color = fillColor;
            shape.Line.FillType = Aspose.Cells.Drawing.FillType.Solid;
            shape.Line.SolidFill.Color = borderColor;
        }

Please find attached the output Excel file for your reference.
out1.zip (7.1 KB)

Hope, this helps a bit.

@amjad.sahi
Thank you for the quick reply

@tejas.patel,

You are welcome. If you have any additional questions or feedback, please do not hesitate to reach out to us.

Could you please tell me is there any other way for better performance to archive same result ?

@tejas.patel,

We need to browse body text paragraphs to apply formatting to each line inside shapes. Do you see any significant performance issue, kindly give us complete details and sample (runnable) code? We will check it soon.

Till now there is no performance related issue working very smooth, i asked because i would like to know if there is any other way.

@amjad.sahi again Thank you

@tejas.patel,

Alright. You are welcome.