Infragistics Excelライブラリでは、WorksheetShape.createPredefinedShape()メソッドを使用して以下の事前定義された図形を新規作成することができます。

形式PredefinedShapeType
Line
ひし形Diamond
楕円Ellipse
ハートHeart
爆発 1IrregularSeal1
爆発 2IrregularSeal2
五角形Pentagon
正方形/長方形Rectangle
直角三角形RightTriangle
稲妻LightningBolt
//新規のWorkbookを作成します。
const workbook = new Workbook(WorkbookFormat.Excel2007);
//Worksheetを追加します。
const sheet = workbook.worksheets().add('Sheet1');

// WorksheetShape.createPredefinedShapeメソッドを使用してRectangleのShapeを作成します。
const shape = WorksheetShape.createPredefinedShape(PredefinedShapeType.Rectangle);
//fillプロパティで塗りつぶしの色を設定します。
shape.fill = ShapeFill.fromColor("SteelBlue");
//outlineプロパティで線の色を設定します。
shape.outline = ShapeOutline.fromColor("Red");
//Shapeを配置するセルと位置をtopLeftCornerCell、topLeftCornerPosition、bottomRightCornerCell、bottomRightCornerPositionプロパティで指定します。
shape.topLeftCornerCell = sheet.rows(2).cells(2);
shape.topLeftCornerPosition = { x: 50, y: 100 };
shape.bottomRightCornerCell = sheet.rows(10).cells(5);
shape.bottomRightCornerPosition = { x: 50, y: 100 };
//テキストを追加する場合は、ShapeをRectangleShapeにキャストしてから、textプロパティにFormattedTextを設定します。
const ft = new FormattedText("infragistics");
(shape as RectangleShape).text = ft;
ft.getFont(0, 12).bold = true;
const color = new Color(); 
color.colorString = "Yellow";
ft.getFont(0, 12).colorInfo = new WorkbookColorInfo(color);
ft.getFont(0, 1).height = 1000;
ft.getFont(5, 1).height = 1000;
//最後に、WorksheetのshapesコレクションにShapeを追加します。
sheet.shapes().add(shape);
Tagged:

製品について

Ignite UI for Web Components