各行が異なる水平方向の整列を持つテキストボックスを作成
Contents
[
Hide
]
段落テキストの水平方向の配置を設定することができます。TextParagraph.alignment_typeプロパティを使用します。
以下のサンプルコードは、三つの行を作成し、それぞれの水平方向の配置を設定します。
This file contains hidden or 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
from aspose.cells import SaveFormat, TextAlignmentType, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create a workbook. | |
wb = Workbook() | |
# Access first worksheet. | |
ws = wb.worksheets[0] | |
# Add text box inside the sheet. | |
ws.shapes.add_text_box(2, 0, 2, 0, 80, 400) | |
# Access first shape which is a text box and set is text. | |
shape = ws.shapes[0] | |
shape.text = "Sign up for your free phone number.\nCall and text online for free.\nCall your friends and family." | |
# Acccess the first paragraph and set its horizontal alignment to left. | |
p = shape.text_body.text_paragraphs[0] | |
p.alignment_type = TextAlignmentType.LEFT | |
# Acccess the second paragraph and set its horizontal alignment to center. | |
p = shape.text_body.text_paragraphs[1] | |
p.alignment_type = TextAlignmentType.CENTER | |
# Acccess the third paragraph and set its horizontal alignment to right. | |
p = shape.text_body.text_paragraphs[2] | |
p.alignment_type = TextAlignmentType.RIGHT | |
# Save the workbook in xlsx format. | |
wb.save(dataDir + "output_out.xlsx", SaveFormat.XLSX) |