通过Node.js和C++将多个工作簿合并为一个工作簿

将具有图像和图表的工作簿合并

示例代码结合了两个工作簿到一个工作簿,使用Aspose.Cells for Node.js via C++。代码加载源工作簿,使用Workbook.combine(Workbook)方法合并它们,并保存输出工作簿。

源工作簿

输出工作簿

屏幕截图

以下是源和输出工作簿的屏幕截图。

图表工作簿的第一个工作表 - 堆叠

todo:image_alt_text

图表工作簿的第二个工作表 - 折线

todo:image_alt_text

图片工作簿的第一个工作表 - 图片

todo:image_alt_text

组合工作簿中的三个工作表 - 堆叠、线条、图片

todo:image_alt_text

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

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

// Define the first source
// Open the first excel file.
const sourceBook1 = new AsposeCells.Workbook(path.join(dataDir, "SampleChart.xlsx"));

// Define the second source book.
// Open the second excel file.
const sourceBook2 = new AsposeCells.Workbook(path.join(dataDir, "SampleImage.xlsx"));

// Combining the two workbooks
sourceBook1.combine(sourceBook2);

const outputPath = path.join(dataDir, "Combined.out.xlsx");
// Save the target book file.
sourceBook1.save(outputPath);

高级主题