Bir Şekilde veya Metin Kutusunda Paragrafın Satır Aralığını Ayarlama
Contents
[
Hide
]
Sırasıyla TextParagraph.LineSpace, TextParagraph.SpaceBefore ve TextParagraph.SpaceAfter’ı kullandıktan sonra paragrafın satır aralığını, önündeki boşluğu ve sonraki boşluğu ayarlayabilirsiniz.
Bir Şekilde veya Metin Kutusunda Paragrafın Satır Aralığını Ayarlama
Aşağıdaki örnek kod, belirtilen özelliklerin kullanımını açıklar. Lütfen indirinçıktı excel dosyası referansınız için kod tarafından oluşturulur.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(SetLineSpacingofParagraph.class); | |
// Create a workbook | |
Workbook wb = new Workbook(); | |
// Access first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
// Add text box inside the sheet | |
ws.getShapes().addShape(MsoDrawingType.TEXT_BOX, 2, 0, 2, 0, 100, 200); | |
// Access first shape which is a text box and set is text | |
Shape shape = ws.getShapes().get(0); | |
shape.setText("Sign up for your free phone number.\nCall and text online for free."); | |
// Acccess the first paragraph | |
TextParagraph p = shape.getTextBody().getTextParagraphs().get(1); | |
// Set the line space | |
p.setLineSpaceSizeType(LineSpaceSizeType.POINTS); | |
p.setLineSpace(20); | |
// Set the space after | |
p.setSpaceAfterSizeType(LineSpaceSizeType.POINTS); | |
p.setSpaceAfter(10); | |
// Set the space before | |
p.setSpaceBeforeSizeType(LineSpaceSizeType.POINTS); | |
p.setSpaceBefore(10); | |
// Save the workbook in xlsx format | |
wb.save(dataDir + "output.xlsx", SaveFormat.XLSX); |