Imposta i margini del commento o della forma all'interno del foglio di lavoro
Contents
[
Hide
]
Possibili scenari di utilizzo
Aspose.Cells consente di impostare i margini di qualsiasi forma o commento utilizzando ilShape.TextBody.TextAlignment proprietà. Questa proprietà restituisce l’oggetto diShapeTextAlignment classe che ha proprietà diverse, ad esTopMarginPt, Margine SinistroPt, BottomMarginPt, Margine destroPt, ecc. che possono essere utilizzati per impostare i margini superiore, sinistro, inferiore e destro.
Imposta i margini del commento o della forma all’interno del foglio di lavoro
Vedere il seguente codice di esempio. Carica ilesempio di file Excel che contiene due forme. Il codice accede alle forme una per una e ne imposta i margini superiore, sinistro, inferiore e destro. Si prega di consultare ilfile Excel di output generato dal codice e screenshot che mostra l’effetto del codice sul file Excel di output.
Codice d’esempio
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 | |
//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"); |