Set the shadow style for the shape on Excel worksheet in C#

With the help of Spire.XLS, we can easily add shapes to the Excel worksheet. This article will demonstrate how to format the shadow of shape on Excel in C#. We can use Spire.XLS to set the color, size, blur, angle, transparency and distance of the shadow for the shape on Excel worksheet.

Set the shadow style when we add new shape to the Excel worksheet:

using Spire.Xls;
using Spire.Xls.Core;
using System.Drawing;
namespace SetShadowStyle
{
    class Program
    {
        static void Main(string[] args)
        {
            //instantiate a Workbook object and get the first worksheet
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];

            //add an ellipse shape
            IPrstGeomShape ellipse = sheet.PrstGeomShapes.AddPrstGeomShape(5, 5, 150, 100, PrstGeomShapeType.Ellipse);

            //set the shadow style for the ellipse
            ellipse.Shadow.Angle = 90;
            ellipse.Shadow.Distance = 10;
            ellipse.Shadow.Size = 150;
            ellipse.Shadow.Color = Color.Gray;
            ellipse.Shadow.Blur = 30;
            ellipse.Shadow.Transparency = 1;
            ellipse.Shadow.HasCustomStyle = true;

            //save the document to file
            workbook.SaveToFile("Shapeshadow.xlsx", FileFormat.Version2010);
        }
    }
}

Effective screenshot after setting the shadow style for the shape on the Excel worksheet:

Set the shadow style for the shape on Excel worksheet in C#

Set the shadow style when we loaded an Excel document with shape:

using Spire.Xls;
using Spire.Xls.Core;
using System.Drawing;
namespace SetShadowStyle
{
    class Program
    {
        static void Main(string[] args)
        {
            //create an instance of workbook and load the document from file
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("Sample.xlsx");

            //get the first worksheet from the sample document
            Worksheet sheet = workbook.Worksheets[0];

            //get the first shape from the worksheet
            IPrstGeomShape shape = sheet.PrstGeomShapes[0];

            //set the shadow style for the shape
            shape.Shadow.Angle = 90;
            shape.Shadow.Distance = 10;
            shape.Shadow.Size = 120;
            shape.Shadow.Color = Color.Yellow;
            shape.Shadow.Blur = 30;
            shape.Shadow.HasCustomStyle = true;

            //save the document to file
            workbook.SaveToFile("ShadowStyle.xlsx", FileFormat.Version2010);

        }
    }
}

Effective screenshot after setting the shadow style for the shape on the Excel worksheet:

Set the shadow style for the shape on Excel worksheet in C#