Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Sat Mar 18, 2023 8:00 pm

I have created an elip with the following code:

Code: Select all
IPrstGeomShape circle = wosh.PrstGeomShapes.AddPrstGeomShape(31, 19, 70, 70, PrstGeomShapeType.Ellipse);
circle.Fill.ForeColor = Color.DarkBlue;
circle.Fill.FillType = ShapeFillType.NoFill;
circle.Text = "USER 2020";


Is there a way for the text inside to come out in bold and in one color?
and that the edge of the ellipse is thicker?

PolloKulos
 
Posts: 11
Joined: Sun Mar 28, 2021 3:23 am

Mon Mar 20, 2023 10:22 am

Hi

Thanks for your message.
You can refer to the following code to achieve your demand.If there is any other problem, just feel free to write back.
Code: Select all
            Workbook workbook = new Workbook();
            Worksheet wosh = workbook.Worksheets[0];
            //create a font
            ExcelFont font = workbook.CreateFont();
            font.FontName = "Calibri";
            font.Size = 10;
            font.IsBold = true;
            font.Color = Color.Red;
            //add shape
            IPrstGeomShape Ellipse = wosh.PrstGeomShapes.AddPrstGeomShape(2, 3, 100, 100, PrstGeomShapeType.Ellipse);
            Ellipse.Fill.ForeColor = Color.DarkBlue;
            Ellipse.Fill.FillType = ShapeFillType.NoFill;
            Ellipse.Text = "USER 2020";
            //setting
            XlsShape shape = Ellipse as XlsShape;
            shape.RichText.SetFont(0, shape.RichText.Text.ToArray().Length - 1, font);
            shape.Line.Weight = 2;
            //save
            workbook.SaveToFile(@"in_out2.xlsx", ExcelVersion.Version2013);

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Tue Mar 21, 2023 9:46 pm

Hi

It works correctly, I have a question, is there a property to align the text horizontally to the center?
I have only seen the following property, but it is vertically

Code: Select all
shape.TextVerticalAlignment = ExcelVerticalAlignment.MiddleCentered;


Thanks.

PolloKulos
 
Posts: 11
Joined: Sun Mar 28, 2021 3:23 am

Wed Mar 22, 2023 2:28 am

Hello,

Thanks for your feedback.
Kindly note that our Spire.XLS mimics the same behavior as MS Excel does. As the following screenshot, to align the text horizontally, you can adjust the left and right margins, the below code is the corresponding settings of our product.
FormatShape.png
FormatShape.png (25.27 KiB) Viewed 885 times

Code: Select all
Ellipse.TextFrame.LeftMarginPt = 10;
Ellipse.TextFrame.RightMarginPt = 10;

If there is any other issues, just feel free to write back.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1271
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.XLS