2

これは私のコードです:

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」のような形式の角丸長方形を作成したいのですが、誰か助けてください。

4

1 に答える 1

3

EPPLUSを使用すると、多くの形状がサポートされます。

プロジェクトに参照を追加するだけです。

角丸四角形を追加するには、次の名前空間とコード スニペットを含めます。

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();
于 2012-11-28T12:29:32.207 に答える