使用C#在excel中创建一个矩形?

使用C#在excel中创建一个矩形?,c#,winforms,excel,C#,Winforms,Excel,这是我的代码: using Excel = Microsoft.Office.Interop.Excel; Excel.Application xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, 47, 280, 140, 90); xlWorkSheet.Shapes.AddTextEffec

这是我的代码:

using Excel = Microsoft.Office.Interop.Excel;

Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, 47, 280, 140, 90);
xlWorkSheet.Shapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect1, "simple text", "Arial", 14, MsoTriState.msoTrue, MsoTriState.msoFalse, 67, 320);
我想创建一个圆角矩形,格式类似于MS Office 2010中的“彩色轮廓-橙色,重音6”。有人帮我吗?

你可以使用很多支持的形状

只需将引用添加到项目中

在下面包含以下名称空间和代码段以添加圆角矩形

using OfficeOpenXml;
using OfficeOpenXml.Style;
using OfficeOpenXml.Drawing;       

FileInfo newFile = new FileInfo(@"C:\ExcelFiles\RoundedRectangle.xlsx");
ExcelPackage pck = new ExcelPackage(newFile);
//Add the Content sheet
var ws = pck.Workbook.Worksheets.Add("MySheet");
ws.View.ShowGridLines = false;
var shape = ws.Drawings.AddShape("Description", eShapeStyle.RoundRect);
shape.SetPosition(0, 5, 5, 5);
shape.SetSize(400, 200);
shape.Text = "Text inside the round rectangle";
shape.Fill.Style = eFillStyle.SolidFill;
shape.Fill.Transparancy = 20;
shape.Border.Fill.Style = eFillStyle.SolidFill;
shape.Border.LineStyle = eLineStyle.LongDash;
shape.Border.Width = 1;
shape.Border.Fill.Color = Color.Black;
shape.Border.LineCap = eLineCap.Round;
shape.TextAnchoring = eTextAnchoringType.Top;
shape.TextVertical = eTextVerticalType.Horizontal;
shape.TextAnchoringControl = false;

pck.Save();