Shape Ön veya Arka Plan Sendesiyle Tekne İçinde Node.js kullanımıyla şekil gönderme

Olası Kullanım Senaryoları

Birden fazla şeklin aynı konumda bulunduğu durumlarda, görünürlükleri Z sırasına göre belirlenir. Aspose.Cells Shape.toFrontOrBack() metodunu sağlar, bu da şeklin Z sırasını değiştirir. Bir şekli arkaya göndermek için negatif bir sayı kullanırsınız, örneğin -1, -2, -3, vb., ve öne getirmek için pozitif bir sayı kullanırsınız, örneğin 1, 2, 3, vb.

Çalışma Sayfası İçinde Şekil Önüne veya Arkasına Gönderme

Aşağıdaki örnek kod, Shape.toFrontOrBack() metodunun kullanımını açıklar. Kodda kullanılan örnek Excel dosyasını ve bunun oluşturduğu çıktı Excel dosyasını görebilirsiniz. Ekran görüntüsü kodun çalıştırılmasıyla sample Excel dosyasındaki etkisini gösterir.

todo:image_alt_text

Örnek Kod

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const sourceFilePath = path.join(dataDir, "sampleToFrontOrBack.xlsx");

// Load source Excel file
const workbook = new AsposeCells.Workbook(sourceFilePath);

// Access first worksheet
const worksheet = workbook.getWorksheets().get(0);

// Access first and fourth shape
const shape1 = worksheet.getShapes().get(0);
const shape4 = worksheet.getShapes().get(3);

// Print the Z-Order position of the shape
console.log("Z-Order Shape 1: " + shape1.getZOrderPosition());

// Send this shape to front
shape1.toFrontOrBack(2);

// Print the Z-Order position of the shape
console.log("Z-Order Shape 4: " + shape4.getZOrderPosition());

// Send this shape to back
shape4.toFrontOrBack(-2);

// Save the output Excel file
const outputFilePath = path.join(dataDir, "outputToFrontOrBack.xlsx");
workbook.save(outputFilePath);