Node.js ile C++ kullanarak Excel Sayfası Transparan Görüntüsü Oluşturma
Contents
[
Hide
]
Bazen çalışma sayfanızın görüntüsünü şeffaf bir görüntü olarak oluşturmanız gerekebilir. Dolgu renkleri olmayan tüm hücrelere şeffaflık uygulamak istersiniz. Aspose.Cells, çalışma sayfasına şeffaflık uygulamak için ImageOrPrintOptions.getTransparent() özelliğini sağlar. Bu özellik false olduğunda, dolgu renkleri olmayan hücreler beyaz renkle çizilir ve true olduğunda, dolgu renkleri olmayan hücreler şeffaf şekilde çizilir.
Aşağıdaki çalışma sayfası görüntüsünde şeffaflık uygulanmamıştır. Dolgu rengi olmayan hücreler beyaz olarak çizilmiştir.
Şeffaflık olmadan çıktı: hücre arka planı beyazdır |
---|
![]() |
Ancak aşağıdaki çalışma sayfası görüntüsünde şeffaflık uygulanmıştır. Dolgu rengi olmayan hücreler şeffaf olarak çizilmiştir.
Şeffaflık etkinleştirilmiş çıktı |
---|
![]() |
Aşağıdaki örnek kod, bir Excel çalışma sayfasından şeffaf bir görüntü oluşturur.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// Source directory
const sourceDir = path.join(__dirname, "data");
// Output directory
const outputDir = path.join(__dirname, "output");
// Create workbook object from source file
const wb = new AsposeCells.Workbook(path.join(sourceDir, "sampleCreateTransparentImage.xlsx"));
// Apply different image or print options
const imgOption = new AsposeCells.ImageOrPrintOptions();
imgOption.setImageType(AsposeCells.ImageType.Png);
imgOption.setHorizontalResolution(200);
imgOption.setVerticalResolution(200);
imgOption.setOnePagePerSheet(true);
// Apply transparency to the output image
imgOption.setTransparent(true);
// Create image after applying image or print options
const sr = new AsposeCells.SheetRender(wb.getWorksheets().get(0), imgOption);
sr.toImage(0, path.join(outputDir, "outputCreateTransparentImage.png"));