//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); var source_fileStream = GetResourceStream("xlsx\\Financial KPIs.xlsx"); workbook.Open(source_fileStream); IWorksheet worksheet = workbook.ActiveSheet; IShape shape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, worksheet.Range["G2:J3"]); shape.Line.Visible = false; shape.Fill.Color.RGB = Color.FromArgb(91, 155, 213); shape.TextFrame.TextRange.Text = "Treadstone Inc."; shape.TextFrame.TextRange.Font.Size = 20; shape.TextFrame.TextRange.Font.Name = "Calibri"; shape.TextFrame.TextRange.Font.Color.RGB = Color.White; shape.TextFrame.HorizontalAnchor = HorizontalAnchor.Center; shape.TextFrame.VerticalAnchor = VerticalAnchor.AnchorMiddle;
' Create a new Workbook Dim workbook As New Workbook Dim source_fileStream = GetResourceStream("xlsx\\Financial KPIs.xlsx") workbook.Open(source_fileStream) Dim worksheet = workbook.ActiveSheet Dim Shape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, worksheet.Range("G2:J3")) Shape.Line.Visible = False Shape.Fill.Color.RGB = Color.FromArgb(91, 155, 213) With Shape.TextFrame .TextRange.Text = "Treadstone Inc." With .TextRange.Font .Size = 20 .Name = "Calibri" .Color.RGB = Color.White End With .HorizontalAnchor = HorizontalAnchor.Center .VerticalAnchor = VerticalAnchor.AnchorMiddle End With ' save to an excel file workbook.Save("AddShapeToRange.xlsx")