//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); Stream openStream = GetResourceStream("xlsx\\TemplateWorkWithChart.xlsx"); workbook.Open(openStream, OpenFileFormat.Xlsx); IWorksheet worksheet = workbook.Worksheets[0]; IShape shape1 = worksheet.Shapes.AddShape(AutoShapeType.RoundedRectangle, (double)10, (double)10, (double)320, (double)150); shape1.TextFrame.TextRange.TextAlignment = TextAlignmentAnchor.Left; shape1.TextFrame.TextRange.Font.Name = "Calibri"; shape1.TextFrame.TextRange.Font.Size = 16; shape1.TextFrame.TextRange.Font.Color.RGB = Color.Black; shape1.TextFrame.TextRange.Font.Underline = TextUnderlineType.None; shape1.TextFrame.TextRange.Paragraphs.Add("Quarterly Results"); shape1.TextFrame.TextRange.Paragraphs[0].TextAlignment = TextAlignmentAnchor.Center; shape1.TextFrame.TextRange.Paragraphs[0].Font.Size = 28; shape1.TextFrame.TextRange.Paragraphs[0].Font.Underline = TextUnderlineType.Single; shape1.TextFrame.TextRange.Paragraphs.Add(""); shape1.TextFrame.TextRange.Paragraphs.Add("Business Domain: E-Commerce"); shape1.TextFrame.TextRange.Paragraphs[2].TextAlignment = TextAlignmentAnchor.Left; shape1.TextFrame.TextRange.Paragraphs.Add("Quarter: Q4"); shape1.TextFrame.TextRange.Paragraphs[3].TextAlignment = TextAlignmentAnchor.Left; shape1.Line.DashStyle = LineDashStyle.Solid; shape1.Line.Style = LineStyle.Single; shape1.Line.Color.RGB = Color.Black; shape1.Fill.Color.RGB = Color.FromArgb(242, 242, 242); // Save to an excel file workbook.Save("UseCaseOfShapeTextAlignment.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim openStream As Stream = GetResourceStream("xlsx\TemplateWorkWithChart.xlsx") workbook.Open(openStream, OpenFileFormat.Xlsx) Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim shape1 As IShape = worksheet.Shapes.AddShape(AutoShapeType.RoundedRectangle, CDbl(10), CDbl(10), CDbl(320), CDbl(150)) shape1.TextFrame.TextRange.TextAlignment = TextAlignmentAnchor.Left shape1.TextFrame.TextRange.Font.Name = "Calibri" shape1.TextFrame.TextRange.Font.Size = 16 shape1.TextFrame.TextRange.Font.Color.RGB = System.Drawing.Color.Black shape1.TextFrame.TextRange.Font.Underline = TextUnderlineType.None shape1.TextFrame.TextRange.Paragraphs.Add("Quarterly Results") shape1.TextFrame.TextRange.Paragraphs(0).TextAlignment = TextAlignmentAnchor.Center shape1.TextFrame.TextRange.Paragraphs(0).Font.Size = 28 shape1.TextFrame.TextRange.Paragraphs(0).Font.Underline = TextUnderlineType.Single shape1.TextFrame.TextRange.Paragraphs.Add("") shape1.TextFrame.TextRange.Paragraphs.Add("Business Domain: E-Commerce") shape1.TextFrame.TextRange.Paragraphs(2).TextAlignment = TextAlignmentAnchor.Left shape1.TextFrame.TextRange.Paragraphs.Add("Quarter: Q4") shape1.TextFrame.TextRange.Paragraphs(3).TextAlignment = TextAlignmentAnchor.Left shape1.Line.DashStyle = LineDashStyle.Solid shape1.Line.Style = LineStyle.Single shape1.Line.Color.RGB = System.Drawing.Color.Black shape1.Fill.Color.RGB = System.Drawing.Color.FromArgb(242, 242, 242) ' save to an excel file workbook.Save("UseCaseOfShapeTextAlignment.xlsx")