//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; // Add a rectangle IShape rectangle = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 50, 30, 300, 200); // Add rich text to rectangle rectangle.Fill.Color.RGB = System.Drawing.Color.White; // Add first paragraph ITextRange run1 = rectangle.TextFrame.TextRange.Paragraphs[0].Runs.Add(" Doc"); run1.Font.Color.RGB = System.Drawing.Color.Tomato; ITextRange run2 = rectangle.TextFrame.TextRange.Paragraphs[0].Runs.Add("ume"); run2.Font.Color.RGB = System.Drawing.Color.Yellow; ITextRange run3 = rectangle.TextFrame.TextRange.Paragraphs[0].Runs.Add("nts"); run3.Font.Color.RGB = System.Drawing.Color.LightBlue; ITextRange paragraph0 = rectangle.TextFrame.TextRange.Paragraphs[0]; paragraph0.Font.Size = 36; paragraph0.Font.Bold = true; rectangle.TextFrame.TextRange.Paragraphs.Add(" "); // Add second paragraph ITextRange paragraph1 = rectangle.TextFrame.TextRange.Paragraphs.Add(); ITextRange run4 = paragraph1.Runs.Add("Fast, efficient Excel, Word, and PDF APIs for .NET Standard 2.0 and Java"); run4.Font.Color.RGB = System.Drawing.Color.Black; run4.Font.Size = 20; run4.Font.Name = "Agency FB"; rectangle.TextFrame.TextRange.Paragraphs.Add(" "); // Add third paragraph ITextRange paragraph2 = rectangle.TextFrame.TextRange.Paragraphs.Add(); ITextRange run5 = paragraph2.Runs.Add("Take total document control with ultra-fast, low-footprint document APIs for enterprise apps"); run5.Font.Color.RGB = System.Drawing.Color.Black; run5.Font.Size = 16; run5.Font.Name = "Times New Roman"; // Save to a pdf file workbook.Save("ShapeWithText.pdf");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) ' Add a rectangle Dim rectangle As IShape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 50, 30, 300, 200) ' Add rich text to rectangle rectangle.Fill.Color.RGB = Color.White ' Add first paragraph Dim run1 As ITextRange = rectangle.TextFrame.TextRange.Paragraphs(0).Runs.Add(" Doc") run1.Font.Color.RGB = Color.Tomato Dim run2 As ITextRange = rectangle.TextFrame.TextRange.Paragraphs(0).Runs.Add("ume") run2.Font.Color.RGB = Color.Yellow Dim run3 As ITextRange = rectangle.TextFrame.TextRange.Paragraphs(0).Runs.Add("nts") run3.Font.Color.RGB = Color.LightBlue Dim paragraph0 As ITextRange = rectangle.TextFrame.TextRange.Paragraphs(0) paragraph0.Font.Size = 36 paragraph0.Font.Bold = True rectangle.TextFrame.TextRange.Paragraphs.Add(" ") ' Add second paragraph Dim paragraph1 As ITextRange = rectangle.TextFrame.TextRange.Paragraphs.Add() Dim run4 As ITextRange = paragraph1.Runs.Add("Fast, efficient Excel, Word, and PDF APIs for .NET Standard 2.0 and Java") run4.Font.Color.RGB = Color.Black run4.Font.Size = 20 run4.Font.Name = "Agency FB" rectangle.TextFrame.TextRange.Paragraphs.Add(" ") ' Add third paragraph Dim paragraph2 As ITextRange = rectangle.TextFrame.TextRange.Paragraphs.Add() Dim run5 As ITextRange = paragraph2.Runs.Add("Take total document control with ultra-fast, low-footprint document APIs for enterprise apps") run5.Font.Color.RGB = Color.Black run5.Font.Size = 16 run5.Font.Name = "Times New Roman" ' save to a pdf file workbook.Save("ShapeWithText.pdf")