使用Node.js在C++中创建Excel工作表的透明图片

Contents
[ ]

在下面的工作表图片中,没有应用透明度。没有填充颜色的单元格绘制成了白色。

没有透明度的输出:单元格背景为白色
todo:image_alt_text

而在下面的工作表图片中,应用了透明度。没有填充颜色的单元格是透明的。

启用透明度输出
todo:image_alt_text

下面的示例代码从 Excel 工作表生成一个透明的图像。

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"));