ワークシート内のコメントまたはシェイプの余白を設定する

考えられる使用シナリオ

Aspose.Cells を使用すると、任意の図形またはコメントの余白を設定できます。Shape.TextBody.TextAlignment財産。このプロパティは、のオブジェクトを返しますShapeTextAlignmentたとえば、さまざまなプロパティを持つクラス上余白ポイント, 左余白ポイント, BottomMarginPt, 右余白点などを使用して、上、左、下、右の余白を設定できます。

ワークシート内のコメントまたはシェイプの余白を設定する

以下のサンプルコードをご覧ください。それはサンプル Excel ファイル つの形状が含まれています。このコードは、図形に 1 つずつアクセスし、上、左、下、および右の余白を設定します。をご覧ください出力エクセルファイル出力 Excel ファイルに対するコードの効果を示すコードとスクリーンショットによって生成されます。

todo:画像_代替_文章

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Load the sample Excel file
Workbook wb = new Workbook("sampleSetMarginsOfCommentOrShapeInsideTheWorksheet.xlsx");
//Access first worksheet
Worksheet ws = wb.getWorksheets().get(0);
for(int idx =0; idx<ws.getShapes().getCount(); idx++)
{
//Access the shape
Shape sh = ws.getShapes().get(idx);
//Access the text alignment
ShapeTextAlignment txtAlign = sh.getTextBody().getTextAlignment();
//Set auto margin false
txtAlign.setAutoMargin(false);
//Set the top, left, bottom and right margins
txtAlign.setTopMarginPt(10);
txtAlign.setLeftMarginPt(10);
txtAlign.setBottomMarginPt(10);
txtAlign.setRightMarginPt(10);
}
//Save the output Excel file
wb.save("outputSetMarginsOfCommentOrShapeInsideTheWorksheet.xlsx");