-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShapeHelper.cs
44 lines (39 loc) · 1.42 KB
/
ShapeHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using iDiTect.Excel.Drawing;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace iDiTect.Excel.Demo
{
public static class ShapeHelper
{
public static void AddShapeToSheet()
{
var excelApp = new Application();
var worksheet = excelApp.Workbook.Worksheets.Add("ShapeSheet");
//Add a rectangle shape
var shape = worksheet.Drawings.AddShape("rectangle", ShapeStyle.Rect);
//Set shape location and size
shape.SetPosition(2, 10, 2, 10);
shape.SetSize(200, 100);
shape.Text = "First line in shape.\n\rSencond line.";
//Customize shape fill style
shape.Fill.Style = FillStyle.SolidFill;
shape.Fill.Color = Color.LightBlue;
shape.Fill.Transparancy = 30;
//Change border style
shape.Border.Fill.Style = FillStyle.SolidFill;
shape.Border.LineStyle = LineStyle.Dash;
shape.Border.Width = 1;
shape.Border.Fill.Color = Color.Black;
shape.Border.LineCap = LineCap.Round;
//Set text alignment
shape.TextAnchoring = TextAnchoringType.Top;
shape.TextVertical = TextVerticalType.Horizontal;
shape.TextAnchoringControl = true;
excelApp.Save("shape.xlsx");
}
}
}