ワークシート内のコメントまたはシェイプの余白を設定する
Contents
[
Hide
]
考えられる使用シナリオ
Aspose.Cells を使用すると、任意の図形またはコメントの余白を設定できます。Shape.TextBody.TextAlignment財産。このプロパティは、のオブジェクトを返しますAspose.Cells.Drawing.Texts.ShapeTextAlignmentたとえば、さまざまなプロパティを持つクラス上余白ポイント, 左余白ポイント, BottomMarginPt, 右余白点などを使用して、上、左、下、右の余白を設定できます。
ワークシート内のコメントまたはシェイプの余白を設定する
以下のサンプルコードをご覧ください。それはサンプル Excel ファイル つの形状が含まれています。このコードは、図形に 1 つずつアクセスし、上、左、下、および右の余白を設定します。をご覧ください出力エクセルファイル出力 Excel ファイルに対するコードの効果を示すコードとスクリーンショットによって生成されます。
サンプルコード
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-.NET | |
//Load the sample Excel file | |
Workbook wb = new Workbook("sampleSetMarginsOfCommentOrShapeInsideTheWorksheet.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
foreach (Shape sh in ws.Shapes) | |
{ | |
//Access the text alignment | |
Aspose.Cells.Drawing.Texts.ShapeTextAlignment txtAlign = sh.TextBody.TextAlignment; | |
//Set auto margin false | |
txtAlign.IsAutoMargin = false; | |
//Set the top, left, bottom and right margins | |
txtAlign.TopMarginPt = 10; | |
txtAlign.LeftMarginPt = 10; | |
txtAlign.BottomMarginPt = 10; | |
txtAlign.RightMarginPt = 10; | |
} | |
//Save the output Excel file | |
wb.Save("outputSetMarginsOfCommentOrShapeInsideTheWorksheet.xlsx"); |