//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; IShape shape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 1, 10, 250, 200); IShape shape2 = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 300, 10, 250, 200); //set the margin of text shape.TextFrame.MarginBottom = 40; shape.TextFrame.MarginLeft = 40; shape.TextFrame.MarginRight = 40; shape.TextFrame.MarginTop = 40; shape.TextFrame.TextRange.Paragraphs[0].Runs.Add("Test setting margin for text in a shape"); shape2.TextFrame.TextRange.Paragraphs[0].Runs.Add("Test input text with default margin"); // Save to an excel file workbook.Save("SetMarginOfShapeText.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) With worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 1, 10, 250, 200).TextFrame .MarginBottom = 40 .MarginLeft = 40 .MarginRight = 40 .MarginTop = 40 .TextRange.Paragraphs(0).Runs.Add("Test setting margin for text in a shape") End With Dim shape2 As IShape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 300, 10, 250, 200) shape2.TextFrame.TextRange.Paragraphs(0).Runs.Add("Test input text with default margin") ' save to an excel file workbook.Save("SetMarginOfShapeText.xlsx")