Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.Cells allows you to set the margins of any shape or comment using the Shape.textBody.textAlignment property. This property returns an object of the Aspose.Cells.Drawing.Texts.ShapeTextAlignment class, which provides several properties such as ShapeTextAlignment.getTopMarginPt(), ShapeTextAlignment.getLeftMarginPt(), ShapeTextAlignment.getBottomMarginPt(), ShapeTextAlignment.getRightMarginPt(), etc., which can be used to set the top, left, bottom, and right margins.
Please see the following sample code. It loads the sample Excel file that contains two shapes. The code accesses the shapes one by one and sets their top, left, bottom, and right margins. Please see the output Excel file generated by the code and the screenshot showing the effect on the output file.

const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sampleSetMarginsOfCommentOrShapeInsideTheWorksheet.xlsx");
// Load the sample Excel file
const workbook = new AsposeCells.Workbook(filePath);
// Access the first worksheet
const ws = workbook.getWorksheets().get(0);
const shapes = ws.getShapes();
for (let i = 0; i < shapes.getCount(); i++) {
const sh = shapes.get(i);
// Access the text alignment
const txtAlign = sh.getTextBody().getTextAlignment();
// Set auto margin to false
txtAlign.setIsAutoMargin(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
workbook.save("outputSetMarginsOfCommentOrShapeInsideTheWorksheet.xlsx");
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.